summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas de Zeeuw <thomasdezeeuw@gmail.com>2018-01-11 15:31:51 +0100
committerThomas de Zeeuw <thomasdezeeuw@gmail.com>2018-01-11 15:31:51 +0100
commit992c293e8822b3ee00b251633345459822ba4111 (patch)
tree3c32a0ef2be62475c420a21f504cfd640cc8de15
parent2478f0fa44b548bfe3a120f8a4fef61e73cf7ba4 (diff)
downloadnix-992c293e8822b3ee00b251633345459822ba4111.zip
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.
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/unistd.rs10
-rw-r--r--test/sys/test_wait.rs5
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)));