aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/channel.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-04-14 12:03:34 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-04-15 18:23:11 +0200
commit8fa0b8051dbe2f4e4a00c162913886a34bf78bfa (patch)
treea40e209b552921c4657280046e9573eb4e7dd759 /src/nvim/channel.c
parentc8f409c2f297180ee06b474ef59653aebb817a4a (diff)
downloadrneovim-8fa0b8051dbe2f4e4a00c162913886a34bf78bfa.tar.gz
rneovim-8fa0b8051dbe2f4e4a00c162913886a34bf78bfa.tar.bz2
rneovim-8fa0b8051dbe2f4e4a00c162913886a34bf78bfa.zip
job-control: mitigate process-kill race
children_kill_cb() is racey. One obvious problem is that process_close_handles() is *queued* by on_process_exit(), so when children_kill_cb() is invoked, the dead process might still be in the `loop->children` list. If the OS already reclaimed the dead PID, Nvim may try to SIGKILL it. Avoid that by checking `proc->status`. Vim doesn't have this problem because it doesn't attempt to kill processes that ignored SIGTERM after a timeout. closes #8269
Diffstat (limited to 'src/nvim/channel.c')
-rw-r--r--src/nvim/channel.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 776e2bfa86..4e6ca8d278 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -658,9 +658,9 @@ static void channel_process_exit_cb(Process *proc, int status, void *data)
terminal_close(chan->term, msg);
}
- // if status is -1 the process did not really exit,
- // we just closed the handle onto a detached process
- if (status >= 0) {
+ // If process did not exit, we only closed the handle of a detached process.
+ bool exited = (status >= 0);
+ if (exited) {
process_channel_event(chan, &chan->on_exit, "exit", NULL, 0, status);
}