vim-patch:8.1.0572: stopping a job does not work properly on OpenBSD

Problem:    Stopping a job does not work properly on OpenBSD.
Solution:   Do not use getpgid() to check the process group of the job
            processs ID, always pass the negative process ID to kill().
            (George Koehler, closes vim/vim#3656)
76ab4fd619

Ref: https://github.com/neovim/neovim/issues/9704
Ref: https://github.com/neovim/neovim/issues/10182#issuecomment-514450069
Closes https://github.com/neovim/neovim/pull/10660
This commit is contained in:
Daniel Hahler 2019-07-30 14:16:50 +02:00
parent da87b67812
commit 6e01ed6a4c
2 changed files with 6 additions and 15 deletions

View File

@ -89,21 +89,12 @@ bool os_proc_tree_kill(int pid, int sig)
bool os_proc_tree_kill(int pid, int sig)
{
assert(sig == SIGTERM || sig == SIGKILL);
int pgid = getpgid(pid);
if (pgid > 0) { // Ignore error. Never kill self (pid=0).
if (pgid == pid) {
ILOG("sending %s to process group: -%d",
sig == SIGTERM ? "SIGTERM" : "SIGKILL", pgid);
int rv = uv_kill(-pgid, sig);
return rv == 0;
} else {
// Should never happen, because process_spawn() did setsid() in the child.
ELOG("pgid %d != pid %d", pgid, pid);
}
} else {
ELOG("getpgid(%d) returned %d", pid, pgid);
if (pid == 0) {
// Never kill self (pid=0).
return false;
}
return false;
ILOG("sending %s to PID %d", sig == SIGTERM ? "SIGTERM" : "SIGKILL", -pid);
return uv_kill(-pid, sig) == 0;
}
#endif

View File

@ -797,7 +797,7 @@ describe('jobs', function()
eq(ppid, info.ppid)
end
-- Kill the root of the tree.
funcs.jobstop(j)
eq(1, funcs.jobstop(j))
-- Assert that the children were killed.
retry(nil, nil, function()
for _, child_pid in ipairs(children) do