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:
Justin M. Keyes
2018-04-14 12:03:34 +02:00
parent c8f409c2f2
commit 8fa0b8051d
3 changed files with 17 additions and 16 deletions

View File

@@ -5033,10 +5033,9 @@ jobstart({cmd}[, {opts}]) *jobstart()*
width : (pty only) Width of the terminal screen
height : (pty only) Height of the terminal screen
TERM : (pty only) $TERM environment variable
detach : (non-pty only) Detach the job process from the
nvim process. The process will not get killed
when nvim exits. If the process dies before
nvim exits, "on_exit" will still be invoked.
detach : (non-pty only) Detach the job process: it will
not be killed when Nvim exits. If the process
exits before Nvim, "on_exit" will be invoked.
{opts} is passed as |self| dictionary to the callback; the
caller may set other keys to pass application-specific data.