4 ms·
`kill(id, sig)` sends signal `sig` to pid `id`. `kill(-id, sig)` sends signal `sig` to process group `id`. `kill(-1, ...)` would signal pgid 1, which would be
by burke 9y ago
`kill(id, sig)` sends signal `sig` to pid `id`. `kill(-id, sig)` sends signal `sig` to process group `id`.
`kill(-1, ...)` would signal pgid 1, which would be the process group of init.
From a quick scan of the issue, it looks like maybe nix is using macOS's sandbox feature somehow, maybe that creates a process namespace of sorts and makes `kill(-1, ...)` useful?
EDIT: nvm, there's a special-case for -1:
> If pid equals -1, then sig is sent to every process for which the calling process has permission to send signals, except for process 1 (init)...
I'm surprised this isn't encountered by more people: that seems useful.
- 0x0 9y agoFrom a quick reading of https://groups.google.com/forum/m/#!topic/nix-devel/KV9eomIdxWE https://groups.google.com/forum/m/#!topic/nix-devel/KV9eomId... - it doesn't seem related to sandboxes or anything fancy, it seems like the kill signals go across the basic unix user accounts (uids)
- deleted 9y ago[deleted]
- lstyls 9y ago> that seems useful. It's useful like an atom bomb is useful - a really heavy-handed approach. Usually this is a smell that indicates forking processes are not communicating well. It's much better to have well-behaved processes. Send SIGTERM to the parent process, allow the parent to perform cleanup of its own children recursively.
- ars 9y ago> It's useful like an atom bomb is useful It's intended for when you reboot the system, to get every process to quit. And for when you logout, to close everything you have running. So yes, useful.
- lstyls 9y agoWut? When logging out via the OS supplied method this is handled for the user. Why on earth would a user have to call kill -1 on logout? My comment was from the perspective of an application developer.
- ars 9y ago`kill(-1, ...)` is a syscall, it's not an application command. > this is handled for the user. And that's how - they call that syscall. Maybe you didn't realize. Notice the parenthesis? It's a function call in a programming language. The command line program is just a passthrough to the syscall. And when rebooting you do need the command line program, so preventing it from passing -1 through doesn't make sense either.