diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-11-11 19:11:46 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-11-11 19:11:46 +0000 |
commit | 8f2468ca1e3dc1a5c6c8372e47443b262e03cba5 (patch) | |
tree | 3eefddcad96a76a1adbc6b149c72b6a7786e8ede | |
parent | 31d242ec63d929abfbe6fc91158700e21dd12d83 (diff) | |
parent | ecd0954394ce56829ad7ea2969b4ce031ab6eade (diff) | |
download | nix-8f2468ca1e3dc1a5c6c8372e47443b262e03cba5.zip |
Merge #787
787: Omit invalid waitpid flags on OpenBSD r=Susurrus a=worr
OpenBSD doesn't have `WEXITED`, `WSTOPPED`, or `WNOWAIT`, so omit those
from that platform.
-rw-r--r-- | src/sys/wait.rs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/sys/wait.rs b/src/sys/wait.rs index ec1241be..019b751f 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -8,10 +8,31 @@ libc_bitflags!( pub struct WaitPidFlag: c_int { WNOHANG; WUNTRACED; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] WEXITED; WCONTINUED; + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] WSTOPPED; /// Don't reap, just poll status. + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos", + target_os = "netbsd"))] WNOWAIT; /// Don't wait on children of other threads in this group #[cfg(any(target_os = "android", target_os = "linux"))] @@ -74,7 +95,7 @@ pub enum WaitStatus { /// child process. This is only returned if `WaitPidFlag::WNOHANG` /// was used (otherwise `wait()` or `waitpid()` would block until /// there was something to report). - StillAlive + StillAlive, } impl WaitStatus { @@ -140,7 +161,7 @@ fn continued(status: i32) -> bool { unsafe { libc::WIFCONTINUED(status) } } -fn decode(pid : Pid, status: i32) -> WaitStatus { +fn decode(pid: Pid, status: i32) -> WaitStatus { if exited(status) { WaitStatus::Exited(pid, exit_status(status)) } else if signaled(status) { @@ -178,10 +199,16 @@ pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Re let option_bits = match options { Some(bits) => bits.bits(), - None => 0 + None => 0, }; - let res = unsafe { libc::waitpid(pid.into().unwrap_or(Pid::from_raw(-1)).into(), &mut status as *mut c_int, option_bits) }; + let res = unsafe { + libc::waitpid( + pid.into().unwrap_or(Pid::from_raw(-1)).into(), + &mut status as *mut c_int, + option_bits, + ) + }; Ok(match try!(Errno::result(res)) { 0 => StillAlive, |