The page "Job Control/Implementing a shell/Launching Jobs" contains a code
snippet on how to launch a job. In this code snippet, a newly launched process
tries to call exec before it knows that the entire pipeline has been created.
This is a bug, because a process may change it's session or otherwise change it
status in a way that will make the shell unable to correctly set the process
group of the following programs in the pipeline. Simple pipelines like 'ls -la
--color|more' seem to break from this, which is strange since ls shouldn't do
anything strange. Therefore, each process should wait for the shell to tell them
that they can launch before calling exec. My proposed method for doing this is
to change the code snippet
if (pgid == 0) pgid = pid;
setpgid (pid, pgid);
tcsetpgrp (shell_terminal, pgid);
while( getpgid(pid) != pgid )
while( tcgetpgrp( 0 ) != pgid )
but there may be other issues with that code.