mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user