diff options
author | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-08-07 15:10:41 +0200 |
---|---|---|
committer | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-08-08 10:05:44 +0200 |
commit | 0370de6cb99a320b67afebe048e9b1d9a7474b13 (patch) | |
tree | c1f94d4336d1f0a8d614283adcc374517785b8f4 /test/sys | |
parent | 607ab97ac64f597e78ab321aedd3063f8e040074 (diff) | |
download | nix-0370de6cb99a320b67afebe048e9b1d9a7474b13.zip |
Add a convenience method .pid() to WaitStatus.
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/test_wait.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs index 8d2ca85f..620a4e33 100644 --- a/test/sys/test_wait.rs +++ b/test/sys/test_wait.rs @@ -37,6 +37,19 @@ fn test_wait_exit() { } } +#[test] +fn test_waitstatus_pid() { + let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test"); + + match fork().unwrap() { + Child => unsafe { _exit(0) }, + Parent { child } => { + let status = waitpid(child, None).unwrap(); + assert_eq!(status.pid(), Some(child)); + } + } +} + #[cfg(any(target_os = "linux", target_os = "android"))] // FIXME: qemu-user doesn't implement ptrace on most arches #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] @@ -47,7 +60,7 @@ mod ptrace { use nix::sys::wait::*; use nix::unistd::*; use nix::unistd::ForkResult::*; - use std::{ptr, process}; + use std::ptr; use libc::_exit; fn ptrace_child() -> ! { |