nix-rust / nix

Rust friendly bindings to *nix APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mechanism to query existing signal handler

cpick opened this issue · comments

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()).

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

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

Sure thing.

I've opened #2190 with my suggested implementation.