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

hints for adding sigsuspend(). #1994

Closed
castilma opened this issue Feb 1, 2023 · 3 comments · Fixed by #2279
Closed

hints for adding sigsuspend(). #1994

castilma opened this issue Feb 1, 2023 · 3 comments · Fixed by #2279

Comments

@castilma
Copy link

castilma commented Feb 1, 2023

I'm a rust beginner and I'd like to practice a bit by adding sigsuspend. But I need some hints.

I thought adding it to SigSet right after wait. Regarding the name I'd choose suspend, since wait had the prefix sig stripped, too.

If sigsuspend returns, it always returns the same value. Is it necessary to return that value to the caller?

Do I have to add some special documentation because it may not return?

@asomers
Copy link
Member

asomers commented Apr 4, 2023

I'm a rust beginner and I'd like to practice a bit by adding sigsuspend. But I need some hints.

I thought adding it to SigSet right after wait. Regarding the name I'd choose suspend, since wait had the prefix sig stripped, too.

Makes sense.

If sigsuspend returns, it always returns the same value. Is it necessary to return that value to the caller?

Not in the success case. But it might also fail with EFAULT.

Do I have to add some special documentation because it may not return?

No.

@castilma
Copy link
Author

castilma commented Apr 7, 2023

Not in the success case. But it might also fail with EFAULT.

There is no 'success' case. It never returns with a success. It's always an 'error' case, where errno is set to distinguish between the errors. And since errno is global, I don't have to return it explicitly, right?

@asomers
Copy link
Member

asomers commented Apr 7, 2023

For this function, failing with EINTR is considered success. And the global errno shouldn't be used in Rust programs. Instead, each function should return its own error code. So to wrap sigsuspend for Rust, I suggest that your wrapper check errno. If EINTR, then return Ok(()). Otherwise, return Err(errno).

@Toru3 Toru3 mentioned this issue Jan 3, 2024
3 tasks
@SteveLauC SteveLauC linked a pull request Jan 7, 2024 that will close this issue
3 tasks
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 a pull request may close this issue.

2 participants