Skip to content
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

Added sigaction_is_default(), sigaction_is_ignore(), and sigaction_current() functions #2190

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cpick
Copy link

@cpick cpick commented Nov 14, 2023

What does this PR do

Provide safe mechanisms to determine whether a signal's action is the default or ignore.
This covers the majority of real-world calls to sigaction() with a NULL action without needing any unsafe code.

Provide an unsafe way to query the currently installed sigaction.

The decision to add sigaction_current() instead of just exposing the (new) sigaction_inner() function was to avoid any confusion over the semantics of passing in a None sigaction argument (eg: someone thinking that it meant remove or reset the action).

This closes #2172

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

Chris Pick added 4 commits November 13, 2023 20:10
Multiple tests run within the same process in an indeterminate order.
Restore the signal handler at the end of the test so other tests aren't
affected.
Provide a way to query the currently installed sigaction.

The decision to add `sigaction_current()` instead of just exposing the
`sigaction_inner()` function was to avoid any confusion over the
semantics of passing in a `None` `sigaction` argument (eg: someone
thinking that it meant remove or reset the action).

This builds towards nix-rust#2172.
Provide safe mechanisms to determine whether a signal's action is the
default or ignore.
This covers the majority of real-world calls to `sigaction()` with a
NULL action without needing any unsafe code.

Fixes nix-rust#2172.
@cpick
Copy link
Author

cpick commented Nov 14, 2023

I've also added a (loosely) related/complementary proposal to add safe functions to ignore and restore signals' actions in #2191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mechanism to query existing signal handler
1 participant