lix/src
Alyssa Ross 7c112351d9
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
2021-02-07 13:56:50 +00:00
..
build-remote Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
cpptoml Revert the enum struct change 2020-06-18 22:11:26 +00:00
libcmd Normalize some error messages 2021-02-04 14:47:28 +01:00
libexpr Include note about type of catched errors in tryEval documentation 2021-02-03 17:14:40 +01:00
libfetchers Add traces to errors while updating flake lock file 2021-01-27 14:02:54 +01:00
libmain Remove mkFlag() 2021-01-27 12:06:03 +01:00
libstore Add more instrumentation for #4270 2021-02-05 15:57:33 +01:00
libutil libutil: EPERM from kill(-1, ...) is fine 2021-02-07 13:56:50 +00:00
nix Merge pull request #4372 from tweag/ca/drvoutputs-commands 2021-02-05 13:03:50 +01:00
nix-build Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-channel Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-collect-garbage Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-copy-closure Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-env Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-instantiate Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
nix-store Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
resolve-system-dependencies Fix macOS build 2021-01-21 12:46:22 +01:00