-
Notifications
You must be signed in to change notification settings - Fork 171
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
Signal
should support arbitrary signals
#1249
Comments
A complication is that glibc does not expose the values of Perhaps we should make functions like Another would be to make |
I think at this point it is safe to assume that the number of reserved signals won't change anymore; it has been the same since the move from libc5 to libc6, and there will almost certainly never be a libc7. If that did change, far too much would break. If you prefer to not bake in that assumption, you could expose the real SIGRTMIN, and let applications handle avoiding the reserved signals. Either way, I don't think you need to make the possibility of sending those signals any more unsafe than any other signal; sending any signal an application doesn't expect can cause problems. So if you want to make something unsafe, I would suggest kill_process rather than the creation of the signal number. |
Change `Signal` from an `enum` to a `struct` wrapper around an `i32` so that it can accomodate values it doesn't know about statically, and add APIs for constructing and working with `SIGRTMIN+n` signal values. This requires making `Signal::from_raw` depend on a new "use-libc-sigrt" feature, as it depends on being able to call into libc. This also adds `Signal::from_raw_unchecked` which does not call into libc and is unsafe. Fixes #1249.
I agree that it's unlikely that libc would claim new I think I've found a good way to approach this, so I've now filed #1292 which has:
Does that look like it'll work for your use cases? |
Having However, I'd really like to be able to work with signals safely without introducing a dependency on libc. Would you consider, as an alternative:
That way, it'd be possible for applications to either depend on libc or hardcode the libc6 ABI, and use safe code. |
Are you writing code which can know it isn't sharing a process with a libc? If so, we could add a safe |
Not necessarily, I'd just like to avoid calling into libc if not necessary.
That would help, and I could live with that being in |
Some datapoints:
None of these necessarily rules out using hardcoded values, but do mean it's worth considering alternatives before doing so. I've now added a patch to #1292 adding |
The
Signal
enum is missing the real-time signals, fromSIGRTMIN
toSIGRTMAX
.Handling these will be interesting, because glibc reserves the first two of them, and does so by changing its exposed value of
SIGRTMIN
.I would suggest exposing the same
SIGRTMIN
that glibc does (34 rather than 32), and additionally exposing enum values for the two reserved signal numbers, with names that clearly indicate that they're reserved by libc.That way, when people port from C to Rust, they won't get surprised by the difference.
The text was updated successfully, but these errors were encountered: