aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/pty_process_unix.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2018-07-13 19:59:09 -0400
committerGitHub <noreply@github.com>2018-07-13 19:59:09 -0400
commit4874214139ab86f7033d5e6c602f7515ed813443 (patch)
tree8a739fe4942649c5ae72c16211c78902700df298 /src/nvim/os/pty_process_unix.c
parent392817c2da46024177e32ac478769d6aad6b4449 (diff)
parentfe913d7838d382075c1dfa8bbf2e652a49b57909 (diff)
downloadrneovim-4874214139ab86f7033d5e6c602f7515ed813443.tar.gz
rneovim-4874214139ab86f7033d5e6c602f7515ed813443.tar.bz2
rneovim-4874214139ab86f7033d5e6c602f7515ed813443.zip
Merge pull request #8737 from dimbleby/overly-general-waitpid
Only waitpid() for processes that we care about
Diffstat (limited to 'src/nvim/os/pty_process_unix.c')
-rw-r--r--src/nvim/os/pty_process_unix.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c
index bd23596ea7..2aeaafe4bd 100644
--- a/src/nvim/os/pty_process_unix.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -273,26 +273,24 @@ 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) {
- if (WIFEXITED(stat)) {
- proc->status = WEXITSTATUS(stat);
- } else if (WIFSIGNALED(stat)) {
- proc->status = WTERMSIG(stat);
- }
- proc->internal_exit_cb(proc);
- break;
+ 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)) {
+ proc->status = WTERMSIG(stat);
}
+ proc->internal_exit_cb(proc);
+ break;
}
}