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

Add suspend to sys::signal::SigSet #1997

Closed
wants to merge 3 commits into from

Conversation

castilma
Copy link

@castilma castilma commented Feb 6, 2023

This adds a simple wrapper for libc::sigsuspend. sigsuspend either doesn't return (if the sighandler terminates the process) or returns -1 and sets errno to EITR. So if this function returns, the return value must be -1 and does not need to be explicitly returned by SigSet::suspend.

In issue #1994 I asked for hints. This is what I got.

I want to add a test, but have difficulties with kill and making sure the test never blocks.

Martin Castillo added 2 commits February 6, 2023 12:48
This adds a simple wrapper for libc::sigsuspend.  `sigsuspend`
either doesn't return (if the sighandler terminates the process) or
returns -1 and sets errno to EITR.  So if this function returns, the
return value must be -1 and does not need to be explicitly returned by
`SigSet::suspend`.
@castilma castilma marked this pull request as ready for review February 6, 2023 14:51
Copy link
Contributor

@VorpalBlade VorpalBlade left a comment

Choose a reason for hiding this comment

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

I'm not affiliated with the nix project, so take this review with a grain of salt. I simply noticed that the project seems a bit overloaded and decided to help.

Overall this seems good. However:

  • There are CI failures that needs to be fixed (obviously)
  • Errno handling for non-Linux might need further investigation.
  • The test feels a bit work in progress to be honest. So I won't really review it in it's current state. TODO comments etc needs to be dealt with.

#[cfg(not(target_os = "redox"))] // Redox does not yet support sigsuspend
#[cfg_attr(docsrs, doc(cfg(all())))]
pub fn suspend(&self) {
unsafe { libc::sigsuspend(&self.sigset as *const libc::sigset_t) };
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the man page it is possible for this to return with EINTR or EFAULT on Linux. EINTR is the normal case for this. But should we handle EFAULT? It can't happen in this abstraction (and would need unsafe in general in Rust):

EFAULT mask points to memory which is not a valid part of the process address space.

But it also feels weird to ignore errors. And I don't have the access to other *nix systems to check if there are other fault conditions in those cases.

@Toru3 Toru3 mentioned this pull request Jan 3, 2024
3 tasks
@SteveLauC
Copy link
Member

Hi @castilma, thanks for your contribution to Nix, this PR didn't get a review due to the lack of review bandwidth, and #2279 implements this in a more complete way, so I am gonna close this, I am really sorry.

@SteveLauC SteveLauC closed this Jan 7, 2024
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

3 participants