diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-02-07 13:56:50 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-02-07 13:56:50 +0000 |
commit | 7c112351d9e941567e64063638396259546d9a48 (patch) | |
tree | 203b4b83df4e02b918d9b948b2cf43f53991e353 /src/libutil/compression.hh | |
parent | 480426a364f09e7992230b32f2941a09fb52d729 (diff) |
libutil: EPERM from kill(-1, ...) is fine
I tested a trivial program that called kill(-1, SIGKILL), which was
run as the only process for an unpriveleged user, on Linux and
FreeBSD. On Linux, kill reported success, while on FreeBSD it failed
with EPERM.
POSIX says:
> If pid is -1, sig shall be sent to all processes (excluding an
> unspecified set of system processes) for which the process has
> permission to send that signal.
and
> The kill() function is successful if the process has permission to
> send sig to any of the processes specified by pid. If kill() fails,
> no signal shall be sent.
and
> [EPERM]
> The process does not have permission to send the signal to any
> receiving process.
My reading of this is that kill(-1, ...) may fail with EPERM when
there are no other processes to kill (since the current process is
ignored). Since kill(-1, ...) only attempts to kill processes the
user has permission to kill, it can't mean that we tried to do
something we didn't have permission to kill, so it should be fine to
interpret EPERM the same as success here for any POSIX-compliant
system.
This fixes an issue that Mic92 encountered[1] when he tried to review a
Nixpkgs PR on FreeBSD.
[1]: https://github.com/NixOS/nixpkgs/pull/81459#issuecomment-606073668
Diffstat (limited to 'src/libutil/compression.hh')
0 files changed, 0 insertions, 0 deletions