Suppress spurious "killing process N: Operation not permitted" on macOS

This commit is contained in:
Eelco Dolstra 2017-06-12 18:34:48 +02:00
parent 25230a17a9
commit 177f3996e2
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -724,8 +724,15 @@ int Pid::kill()
/* Send the requested signal to the child. If it has its own /* Send the requested signal to the child. If it has its own
process group, send the signal to every process in the child process group, send the signal to every process in the child
process group (which hopefully includes *all* its children). */ process group (which hopefully includes *all* its children). */
if (::kill(separatePG ? -pid : pid, killSignal) != 0) if (::kill(separatePG ? -pid : pid, killSignal) != 0) {
printError((SysError(format("killing process %1%") % pid).msg())); /* On BSDs, killing a process group will return EPERM if all
processes in the group are zombies (or something like
that). So try to detect and ignore that situation. */
#if __FreeBSD__ || __APPLE__
if (errno != EPERM || ::kill(pid, 0) != 0)
#endif
printError((SysError("killing process %d", pid).msg()));
}
return wait(); return wait();
} }