From 992c293e8822b3ee00b251633345459822ba4111 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Thu, 11 Jan 2018 15:31:51 +0100 Subject: Remove return value from `pause` `pause` will always return `-1` as a result and sets `errno` to `EINTR`, which indicates that a signal was caught by the process. Since this is the point of `pause` return an error here makes little sense. Closes #827. --- CHANGELOG.md | 3 ++- src/unistd.rs | 10 ++++------ test/sys/test_wait.rs | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aece03d7..3eb1cf9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,7 +94,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Both `ip_mreq` and `ipv6_mreq` have been replaced with `IpMembershipRequest` and `Ipv6MembershipRequest`. ([#814](https://github.com/nix-rust/nix/pull/814)) - +- Removed return type from `pause`. + ([#829](https://github.com/nix-rust/nix/pull/829)) ### Fixed - Fix compilation and tests for OpenBSD targets diff --git a/src/unistd.rs b/src/unistd.rs index 56390d90..0f47a7fc 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1316,14 +1316,12 @@ pub fn initgroups(user: &CStr, group: Gid) -> Result<()> { Errno::result(res).map(|_| ()) } -/// Suspend the thread until a signal is received +/// Suspend the thread until a signal is received. /// -/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html) +/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html). #[inline] -pub fn pause() -> Result<()> { - let res = unsafe { libc::pause() }; - - Errno::result(res).map(drop) +pub fn pause() { + unsafe { libc::pause() }; } /// Suspend execution for an interval of time diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs index 9992607c..2f68e7c4 100644 --- a/test/sys/test_wait.rs +++ b/test/sys/test_wait.rs @@ -12,7 +12,10 @@ fn test_wait_signal() { // Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe. match fork().expect("Error: Fork Failed") { - Child => pause().unwrap_or_else(|_| unsafe { _exit(123) }), + Child => { + pause(); + unsafe { _exit(123) } + }, Parent { child } => { kill(child, Some(SIGKILL)).expect("Error: Kill Failed"); assert_eq!(waitpid(child, None), Ok(WaitStatus::Signaled(child, SIGKILL, false))); -- cgit v1.2.3