From 177f3996e28967368791ba0e4ec036f3dbbb88d0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Jun 2017 18:34:48 +0200 Subject: Suppress spurious "killing process N: Operation not permitted" on macOS --- src/libutil/util.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 16f4b232e6c5..6bf4b3d91805 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -724,8 +724,15 @@ int Pid::kill() /* 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 (which hopefully includes *all* its children). */ - if (::kill(separatePG ? -pid : pid, killSignal) != 0) - printError((SysError(format("killing process %1%") % pid).msg())); + if (::kill(separatePG ? -pid : pid, killSignal) != 0) { + /* 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(); } -- cgit 1.4.1