I think we only want to wait processes which are asynchronous lists. We also
monitor other processes, e.g. command substitutions.
Though it's probably fine anyway, since all of these would have finished anyway
by the time the builtin is called.
waitpid can't be used directly here. We need to our update jobs/processes
internal state when retrieving information from a process.
We could add a function similar to job_wait, which works like waitpid but also
updates our internal state.
Additionally, POSIX says:
> However, the wording means that wait is required to wait for an explicit
> process when it is given an argument so that the status information of other
> processes is not consumed.
But I think it's fine to waitpid with (pid_t)-1 as long as we update our
We can only call this macro if WIFEXITED(stat). Otherwise, the spec says that:
> If the process terminated abnormally due to the receipt of a signal, the exit
> status shall be greater than 128 and shall be distinct from the exit status
> generated by other signals, but the exact value is unspecified.