mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #8737 from dimbleby/overly-general-waitpid
Only waitpid() for processes that we care about
This commit is contained in:
commit
4874214139
@ -273,26 +273,24 @@ static void chld_handler(uv_signal_t *handle, int signum)
|
|||||||
int stat = 0;
|
int stat = 0;
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
do {
|
|
||||||
pid = waitpid(-1, &stat, WNOHANG);
|
|
||||||
} while (pid < 0 && errno == EINTR);
|
|
||||||
|
|
||||||
if (pid <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Loop *loop = handle->loop->data;
|
Loop *loop = handle->loop->data;
|
||||||
|
|
||||||
kl_iter(WatcherPtr, loop->children, current) {
|
kl_iter(WatcherPtr, loop->children, current) {
|
||||||
Process *proc = (*current)->data;
|
Process *proc = (*current)->data;
|
||||||
if (proc->pid == pid) {
|
do {
|
||||||
if (WIFEXITED(stat)) {
|
pid = waitpid(proc->pid, &stat, WNOHANG);
|
||||||
proc->status = WEXITSTATUS(stat);
|
} while (pid < 0 && errno == EINTR);
|
||||||
} else if (WIFSIGNALED(stat)) {
|
|
||||||
proc->status = WTERMSIG(stat);
|
if (pid <= 0) {
|
||||||
}
|
continue;
|
||||||
proc->internal_exit_cb(proc);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WIFEXITED(stat)) {
|
||||||
|
proc->status = WEXITSTATUS(stat);
|
||||||
|
} else if (WIFSIGNALED(stat)) {
|
||||||
|
proc->status = WTERMSIG(stat);
|
||||||
|
}
|
||||||
|
proc->internal_exit_cb(proc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user