[cs631apue] Another question on waiting pipeline.

Jan Schaumann jschauma at stevens.edu
Tue Dec 9 22:26:58 EST 2014

zding4 <zding4 at stevens.edu> wrote:

> $ cmd1 | cmd2 | cmd3
> Our sish should fork subprocesses for each 3 commands.
> Let's say, at the beginning, sish process fork a process to exec cmd1.
> Should it wait for cmd1 (waitpid) before cmd2 and cmd3?

I'm not sure what you mean.  You would not wait for cmd1 to complete
before forking cmd2 or cmd3, since you need to have all three commands
to produce the correct pipeline of input/output file descriptor

You probably want to wait(3) on all of your child processes, I'd think.


More information about the cs631apue mailing list