diff options
-rw-r--r-- | src/libutil/util.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index dad5f624bd00..bc07a84f4d8d 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -12,6 +12,10 @@ #include <fcntl.h> #include <limits.h> +#ifdef __APPLE__ +#include <sys/syscall.h> +#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); |