Skip to content

Commit a09d07b

Browse files
committed
Auto merge of #336 - kamalmarhubi:pause, r=fiveop
unistd: Add pause(2)
2 parents 4eb5918 + 507dfaf commit a09d07b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/unistd.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ pub fn setgid(gid: gid_t) -> Result<()> {
356356
Errno::result(res).map(drop)
357357
}
358358

359+
#[inline]
360+
pub fn pause() -> Result<()> {
361+
let res = unsafe { libc::pause() };
362+
363+
Errno::result(res).map(drop)
364+
}
365+
359366
#[cfg(any(target_os = "linux", target_os = "android"))]
360367
mod linux {
361368
use sys::syscall::{syscall, SYSPIVOTROOT};

test/sys/test_wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use libc::exit;
77
#[test]
88
fn test_wait_signal() {
99
match fork() {
10-
Ok(Child) => loop { /* Wait for signal */ },
10+
Ok(Child) => pause().unwrap_or(()),
1111
Ok(Parent(child_pid)) => {
1212
kill(child_pid, SIGKILL).ok().expect("Error: Kill Failed");
1313
assert_eq!(waitpid(child_pid, None), Ok(WaitStatus::Signaled(child_pid, SIGKILL, false)));

0 commit comments

Comments
 (0)