-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libutil: EPERM from kill(-1, ...) is fine #4530
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: NixOS/nixpkgs#81459 (comment)
10 tasks
uqs
pushed a commit
to freebsd/freebsd-ports
that referenced
this pull request
Feb 8, 2021
Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is MFH: 2021Q1 git-svn-id: svn+ssh://svn.freebsd.org/ports/head@564693 35697150-7ecd-e111-bb59-0022644237b5
uqs
pushed a commit
to freebsd/freebsd-ports
that referenced
this pull request
Feb 8, 2021
Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is MFH: 2021Q1
Jehops
pushed a commit
to Jehops/freebsd-ports-legacy
that referenced
this pull request
Feb 8, 2021
Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is MFH: 2021Q1 git-svn-id: svn+ssh://svn.freebsd.org/ports/head@564693 35697150-7ecd-e111-bb59-0022644237b5
uqs
pushed a commit
to freebsd/freebsd-ports
that referenced
this pull request
Feb 8, 2021
Update to 2.3.10 PR: 251897 Submitted by: nc Differential Revision: https://reviews.freebsd.org/D27996 Fix a runtime issue causing Nix to die when it builds packages Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is
dch
pushed a commit
to skunkwerks/ports
that referenced
this pull request
Feb 9, 2021
Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is MFH: 2021Q1
uqs
pushed a commit
to freebsd/freebsd-ports
that referenced
this pull request
Apr 1, 2021
Update to 2.3.10 PR: 251897 Submitted by: nc Differential Revision: https://reviews.freebsd.org/D27996 Fix a runtime issue causing Nix to die when it builds packages Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is
svmhdvn
pushed a commit
to svmhdvn/freebsd-ports
that referenced
this pull request
Jan 10, 2024
Related upstream PR: NixOS/nix#4530 PR: 253322 Submitted by: hi@alyssa.is MFH: 2021Q1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
and
and
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 encountered1 when he tried to review a
Nixpkgs PR on FreeBSD.