Skip to content

Commit 0d56fff

Browse files
committed
Elaborate on how a shell creates a pipe.
1 parent 13c8091 commit 0d56fff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

proc.tex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,11 +969,15 @@
969969
need to check if \verb#pd[0] == 0#.
970970
\item It is better to create a pipe from a child to its parent as typically the
971971
process writing the pipe finishes first, then the consumer reads the rest of the
972-
data, processes it, and then finally exits. Remember, the shell waits for the
972+
data, processes it, and then finally exits. In general, the shell waits for the
973973
program it started, i.e. the parent, and it does not care at all about children
974974
the running program spawned during its life. If the pipe was created the other
975975
way around, the shell could print the prompt after the parent finished while the
976-
data from the child might still be flowing to the console.
976+
data from the child might still be flowing to the console. However, nowadays
977+
the shell waits for all processes in the pipeline. For example, the following
978+
will take 10 seconds before you get the prompt even though \texttt{cat(1)} might
979+
exit right away if \texttt{sleep(1)} closed its standard error before putting
980+
itself to sleep: \texttt{date | sleep 10 | cat}.
977981
\item For example, the original \emph{Bourne shell} constructed a pipeline the
978982
way that the last process created a child as its producer, that producer itself
979983
created its child as its producer, and this continued until the whole pipeline

0 commit comments

Comments
 (0)