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

Document unimplemented functions. #1315

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sunfishcode
Copy link
Member

Add documentation for several functions which rustix does not implement, or not yet implement, so that users searching for them may learn more.

Add documentation for several functions which rustix does not implement,
or not yet implement, so that users searching for them may learn more.
src/not_implemented.rs Show resolved Hide resolved
///
/// [Eyra]: https://github.com/sunfishcode/eyra?tab=readme-ov-file#eyra
/// [origin]: https://github.com/sunfishcode/origin?tab=readme-ov-file#origin
pub mod libc_internals {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is incomplete - most obviously, there are a lot more pthread functions, and I think there are also more groups of kernel primitives that the C library needs to be intimately involved in any use of, e.g. rseq. It might be better to just say that it's incomplete rather than to try to make it exhaustive.

It's really unfortunate that pthreads implementations for Linux tend to interpose on the signal handling API. As far as I know, C libraries for other kernels do not need to do this. Not having full access to the signal handling API (and the fork/exec API) is a significant hindrance for projects like CLI shells; I think rustix's approach to those ideally ought to be that it calls into libc when configured to use libc as a back end, and makes direct system calls when not so configured.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is incomplete - most obviously, there are a lot more pthread functions, and I think there are also more groups of kernel primitives that the C library needs to be intimately involved in any use of, e.g. rseq. It might be better to just say that it's incomplete rather than to try to make it exhaustive.

The list is for people searching for specific names. So I've gone ahead and added all the pthread_* functions and rseq, and also added a comment saying it's not exhaustive.

It's really unfortunate that pthreads implementations for Linux tend to interpose on the signal handling API. As far as I know, C libraries for other kernels do not need to do this. Not having full access to the signal handling API (and the fork/exec API) is a significant hindrance for projects like CLI shells; I think rustix's approach to those ideally ought to be that it calls into libc when configured to use libc as a back end, and makes direct system calls when not so configured.

I think CLI shells can do everything they need using the public libc APIs to signals and fork/exec. If you want wrappers providing better ergonomics, that could be a separate library. If you don't want to use an actual libc and want direct syscalls, then origin and eyra are where the party's at.

not_implemented!(shmdt);
not_implemented!(shmget);
not_implemented!(shmctl);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signal handling functions in this list (tgkill, raise, signalfd, pidfd_send_signal) belong in the "awkward to provide this without interfering with the system C library" list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These might be ok. It's generally ok to raise signals, because libc's alreaedy have to accept that signals can get raised from outside the process too. We may want to gate them behind cfg(feature = "use-libc-sigrt") and reject reserved signal values though. Or make them unsafe with a safety condition of "don't use reserved signals, on penalty of UB".

Copy link
Member Author

@sunfishcode sunfishcode Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you also mentioned signalfd here. We should think about reserved signals there also, but otherwise, since it doesn't involve actual handlers, it might be ok.

not_implemented!(_Exit);
not_implemented!(exit_group);
not_implemented!(sigpending);
not_implemented!(sigsuspend);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re sigpending and sigsuspend

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tentatively categorized sigpending and sigsuspend as things we may be able to do, because they don't interfere with any signal handlers. But I guess this is all why I inserted some "probably"s into the comments. I haven't thought about all these super deeply yet.

@@ -478,6 +486,9 @@ pub unsafe fn sigprocmask(how: How, set: Option<&Sigset>) -> io::Result<Sigset>

/// `sigpending()`—Query the pending signals.
///
/// If this is ever exposed publicly, we should think about whether it should
/// mask out signals reserved by libc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably similar to how runtime signals are handled --- use libc sigrt in public API, but leave "raw" syscall which doesn't even care about libc in semi-public API

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.

3 participants