I am reading The TTY demystified. In the "Jobs and sessions" section there is an example of a user using an xterm:
$ cat
hello
hello
^Z
[1]+ Stopped cat
$ ls | sort
And there is a table listing the processes involved: xterm
, bash
(child of the xterm
), and the three last processes (cat
, ls
and sort
) all have the same PPID (parent process ID) -- they are all children of the same bash
process.
Now, I know that pipelines in bash are executed in subshells. I have always thought that this subshell thing meant that there was an extra bash
process for each subshell. My question is: shouldn't there be another two bash
processes, both children of the first bash
, and then ls
would be a child of the first bash
, and sort
would be a child of the second bash
? Is the table in the article simplified, or is my understanding of subshells wrong?