I am learning about piping and shell in a Systems class. I’m messing around with strace. I am running it on some program called dpipe.
In the strace log, I see the following:
pipe([3, 4])
pipe([5, 6])
What do those integers represent? I under that piping is basically used in shell to route the output of one command, to the input of another using |. So it just makes our lives easier. In this case, what do the array of numbers up there represent? Furthermore, if piping is just used in shell, why is there C syscall for it? Is that made solely for those who want to write their own shell (to make their lives easier)?
Ignacio explained correctly that the numbers in square brackets are the two file descriptors returned by the
pipe()system call. The first is the read end of the pipe, and the second is the write of the pipe.Pipes are by no means only used by the shell, though that is probably the most common place to use them. However, you have it backwards; the shell can only use the system calls provided by the system, and because the system provides
pipe(), the shell is able to provide piping. Without the support from the o/s in the form of the system call, the shell would be unlikely to provide the pipe notation. All the system calls are there to make it possible for programmers to provide services to their customers (the end users of the software they write).