lix/src/libutil
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
..
tests Improve error formatting 2021-01-21 11:02:09 +01:00
abstract-setting-to-json.hh abstractsettingtojson.hh -> abstract-setting-to-json.hh 2020-09-21 18:49:43 +02:00
affinity.cc affinity operator<< 2020-05-04 14:44:00 -06:00
affinity.hh
ansicolor.hh Fix ANSI color constants 2020-07-12 16:52:20 +02:00
archive.cc read(): Use char * instead of unsigned char * 2020-12-02 14:17:27 +01:00
archive.hh Add forgotten override annotation 2020-12-02 14:23:38 +01:00
args.cc Group common options 2021-01-25 19:03:13 +01:00
args.hh Remove mkFlag() 2021-01-27 12:06:03 +01:00
callback.hh Move Callback into its own header 2020-09-21 18:42:21 +02:00
comparator.hh Move the GENERATE_CMP macro to its own file 2021-02-05 11:42:33 +01:00
compression.cc Sink: Use std::string_view 2020-12-02 14:17:27 +01:00
compression.hh Fix Brotli decompression in 'nix log' 2018-08-06 15:40:29 +02:00
config.cc string2Int(): Return std::optional 2021-01-08 12:22:21 +01:00
config.hh Generalize extra-* settings 2020-10-29 18:17:39 +01:00
error.cc Merge pull request #4467 from edolstra/error-formatting 2021-01-25 12:50:57 +01:00
error.hh Improve error formatting 2021-01-21 11:02:09 +01:00
finally.hh Add missing #include 2016-11-07 14:35:47 +01:00
fmt.hh Formatting 2020-10-07 16:33:19 +02:00
hash.cc Sink: Use std::string_view 2020-12-02 14:17:27 +01:00
hash.hh Sink: Use std::string_view 2020-12-02 14:17:27 +01:00
json.cc Fix build 2020-07-30 15:27:28 +02:00
json.hh Make std::uncaught_exception warning less noisy 2019-10-09 23:04:11 +02:00
local.mk StorePath: Rewrite in C++ 2020-06-16 14:28:41 +02:00
logging.cc Improve error formatting 2021-01-21 11:02:09 +01:00
logging.hh Add lvlNotice log level 2020-12-10 16:41:24 +01:00
lru-cache.hh Missing #include <cassert> in lru-cache.hh (#3654) 2020-06-03 10:15:22 +00:00
monitor-fd.hh monitor-fds: Fix on macOS. 2018-02-14 18:26:37 -05:00
pool.hh RemoteStore: Close connection if an exception occurs 2018-10-16 23:36:15 +02:00
ref.hh Allow setting the state directory as a store parameter 2016-06-02 16:02:48 +02:00
rust-ffi.cc StorePath: Rewrite in C++ 2020-06-16 14:28:41 +02:00
rust-ffi.hh StorePath: Rewrite in C++ 2020-06-16 14:28:41 +02:00
serialise.cc Improve error formatting 2021-01-21 11:02:09 +01:00
serialise.hh read(): Use char * instead of unsigned char * 2020-12-02 14:17:27 +01:00
split.hh Typo 2020-09-17 20:21:04 +02:00
sync.hh sync.hh: return cv_status instead of dropping it, in case useful. 2018-06-18 17:31:00 -05:00
tarfile.cc read(): Use char * instead of unsigned char * 2020-12-02 14:17:27 +01:00
tarfile.hh libarchive proof of concept 2019-12-07 22:35:14 +07:00
thread-pool.cc Fix a hang in ThreadPool 2017-10-09 15:41:09 +02:00
thread-pool.hh Fix extra ; warnings involving MakeError 2019-11-10 11:24:47 -05:00
topo-sort.hh Add missing #pragma once 2020-10-06 10:40:07 +02:00
types.hh Move Explicit 2020-10-26 17:01:20 +01:00
url-parts.hh Merge branch 'slashes-in-github-branches' of https://github.com/Ma27/nix 2021-01-18 12:55:06 +01:00
url.cc Don't include <regex> in header files 2020-09-21 18:22:45 +02:00
url.hh Don't include <regex> in header files 2020-09-21 18:22:45 +02:00
util.cc libutil: EPERM from kill(-1, ...) is fine 2021-02-07 13:56:50 +00:00
util.hh Remove trailing whitespace 2021-01-21 11:02:09 +01:00
xml-writer.cc Cleanup 2019-11-06 16:53:02 +01:00
xml-writer.hh Fix some random -Wconversion warnings 2018-05-02 13:56:34 +02:00