Skip to content

Commit

Permalink
Auto merge of #336 - kamalmarhubi:pause, r=fiveop
Browse files Browse the repository at this point in the history
unistd: Add pause(2)
  • Loading branch information
homu committed Mar 30, 2016
2 parents 4eb5918 + 507dfaf commit a09d07b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ pub fn setgid(gid: gid_t) -> Result<()> {
Errno::result(res).map(drop)
}

#[inline]
pub fn pause() -> Result<()> {
let res = unsafe { libc::pause() };

Errno::result(res).map(drop)
}

#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux {
use sys::syscall::{syscall, SYSPIVOTROOT};
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use libc::exit;
#[test]
fn test_wait_signal() {
match fork() {
Ok(Child) => loop { /* Wait for signal */ },
Ok(Child) => pause().unwrap_or(()),
Ok(Parent(child_pid)) => {
kill(child_pid, SIGKILL).ok().expect("Error: Kill Failed");
assert_eq!(waitpid(child_pid, None), Ok(WaitStatus::Signaled(child_pid, SIGKILL, false)));
Expand Down

0 comments on commit a09d07b

Please sign in to comment.