Do not use up the ~WNOHANG waitpid call on completed processes

This is the more correct fix for #5447, as regardless of which process
in the job (be it the first or the last) finished first, once we have
waited on a process without ~WNOHANG we don't do that for any subsequent
processes in the job.

It is also a waste to call into the kernel to wait for a process we
already know is completed!
This commit is contained in:
Mahmoud Al-Qudsi
2018-12-30 20:46:49 -06:00
parent bfe08a471d
commit 2ebdcf82ee

View File

@@ -478,6 +478,11 @@ static bool process_mark_finished_children(bool block_on_fg) {
break;
}
assert((*process)->pid != INVALID_PID && "Waiting by process on an invalid PID!");
if ((*process)->completed) {
// This process has already been waited on to completion
continue;
}
if ((options & WNOHANG) == 0) {
debug(4, "Waiting on individual process %d", (*process)->pid);
} else {