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

Mechanism to query existing signal handler #2172

Open
cpick opened this issue Oct 20, 2023 · 2 comments · May be fixed by #2190
Open

Mechanism to query existing signal handler #2172

cpick opened this issue Oct 20, 2023 · 2 comments · May be fixed by #2190

Comments

@cpick
Copy link

cpick commented Oct 20, 2023

If NULL is passed as the second (new action) argument to sigaction(), then it won't make any changes, but will return the existing action.

I don't believe nix provides any way to access this behavior. The type of nix::sys::signal::sigaction()s sigaction argument could be changed from &SigAction to Option<&SigAction>, but this would be a breaking change and also would mean doing a read-only query of the current action would only be possible with an unsafe function call.

I'd prefer something like a safe sigaction_get() (roughly akin to this proposal for a sigaction_safe()).

@asomers
Copy link
Member

asomers commented Nov 11, 2023

Could you suggest a complete API, or better yet post a PR?

cpick pushed a commit to cpick/nix that referenced this issue Nov 14, 2023
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.
cpick pushed a commit to cpick/nix that referenced this issue Nov 14, 2023
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.
cpick pushed a commit to cpick/nix that referenced this issue Nov 14, 2023
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

Could you suggest a complete API, or better yet post a PR?

Sure thing.

I've opened #2190 with my suggested implementation.

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 a pull request may close this issue.

2 participants