diff --git a/src/libutil/util.cc b/src/libutil/util.cc index dad5f624bd..bc07a84f4d 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -12,6 +12,10 @@ #include #include +#ifdef __APPLE__ +#include +#endif + #include "util.hh" @@ -851,7 +855,16 @@ void killUser(uid_t uid) throw SysError("setting uid"); while (true) { +#ifdef __APPLE__ + /* OSX's kill syscall takes a third parameter that, among other + things, determines if kill(-1, signo) affects the calling + process. In the OSX libc, it's set to true, which means + "follow POSIX", which we don't want here + */ + if (syscall(SYS_kill, -1, SIGKILL, false) == 0) break; +#else if (kill(-1, SIGKILL) == 0) break; +#endif if (errno == ESRCH) break; /* no more processes */ if (errno != EINTR) throw SysError(format("cannot kill processes for uid `%1%'") % uid);