If the command line ends with &
, we do not call wait
in
the parent process and immediately continue with the next iteration
of the loop. But there is one difficulty: the parent may now have
multiple children executing at the same time (the commands in the
background which haven’t terminated yet, plus the last synchronous
command), and wait
could synchronize with any of these children.
Thus, for synchronous command, wait
must be repeated until the
recovered child is the one actually executing that command.