nix
nix copied to clipboard
Making signal API real-time signal aware
Currently, the nix::sys::signal::sigaction() function uses the Signal enum, which only covers standard signals, but not real-time signals. Using real-time signals with nix requires using the std::mem::transmute() function to assign an impossible value to the Signal enum, which is undefined behavior (and is unsafe for any other use than passing to nix functions, and possible even then).
What does this PR do
In this PR, the nix::sys::signal API is made real-time signal aware by adding the new enum SignalValue that has two variants: Standard that takes Signal values, and Realtime, that takes real-time signal numbers SIGRTMIN+n, where n is the passed number. Most of the functions are left untouched, instead, real-time signal aware versions of the were added with the rt_ prefix (similar to the real-time signal aware system calls in the Linux kernel that glibc uses instead of the old system calls). However, two significant changes have been made: turning SigSet into iterator returns a SignalSetIter instead of real-time signal unaware SigSetIter, and the signal field of structs SigevSignal and SigevThreadId takes the new enum instead of the old one.
Checklist:
- [yes] I have read
CONTRIBUTING.md - [yes] I have written necessary tests and rustdoc comments
- [yes] A change log has been added if this PR modifies nix's API