Merge pull request #8737 from dimbleby/overly-general-waitpid

Only waitpid() for processes that we care about
This commit is contained in:
James McCoy 2018-07-13 19:59:09 -04:00 committed by GitHub
commit 4874214139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,19 +273,18 @@ static void chld_handler(uv_signal_t *handle, int signum)
int stat = 0;
int pid;
do {
pid = waitpid(-1, &stat, WNOHANG);
} while (pid < 0 && errno == EINTR);
if (pid <= 0) {
return;
}
Loop *loop = handle->loop->data;
kl_iter(WatcherPtr, loop->children, current) {
Process *proc = (*current)->data;
if (proc->pid == pid) {
do {
pid = waitpid(proc->pid, &stat, WNOHANG);
} while (pid < 0 && errno == EINTR);
if (pid <= 0) {
continue;
}
if (WIFEXITED(stat)) {
proc->status = WEXITSTATUS(stat);
} else if (WIFSIGNALED(stat)) {
@ -295,4 +294,3 @@ static void chld_handler(uv_signal_t *handle, int signum)
break;
}
}
}