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

Making signal API real-time signal aware #2451

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

Conversation

ChrysoliteAzalea
Copy link

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

@ChrysoliteAzalea
Copy link
Author

I've managed to work out most issues with tests, but I don't know why these three are failing, and why they are failing on mips and pass on everything else. I think I'll have to set up a VM emulating a mips CPU to solve it.

@SteveLauC
Copy link
Member

Hi, thanks for the PR!

I will take a deeper look at how to add realtime signal support and this PR this weekend

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.

None yet

2 participants