Skip to content

Commit 3d294ab

Browse files
committed
Omit invalid waitpid flags on OpenBSD
OpenBSD doesn't have `WEXITED`, `WSTOPPED`, or `WNOWAIT`, so omit those from that platform.
1 parent 1b9d205 commit 3d294ab

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/sys/wait.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@ libc_bitflags!(
88
pub struct WaitPidFlag: c_int {
99
WNOHANG;
1010
WUNTRACED;
11+
#[cfg(any(target_os = "freebsd",
12+
target_os = "linux",
13+
target_os = "android"))]
1114
WEXITED;
1215
WCONTINUED;
16+
#[cfg(any(target_os = "freebsd",
17+
target_os = "linux",
18+
target_os = "android"))]
1319
WSTOPPED;
1420
/// Don't reap, just poll status.
21+
#[cfg(any(target_os = "freebsd",
22+
target_os = "linux",
23+
target_os = "android"))]
1524
WNOWAIT;
1625
/// Don't wait on children of other threads in this group
1726
#[cfg(any(target_os = "android", target_os = "linux"))]
1827
__WNOTHREAD;
1928
/// Wait on all children, regardless of type
20-
#[cfg(any(target_os = "android", target_os = "linux"))]
29+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "netbsd"))]
2130
__WALL;
22-
#[cfg(any(target_os = "android", target_os = "linux"))]
31+
#[cfg(any(target_os = "android", target_os = "linux", target_os = "netbsd"))]
2332
__WCLONE;
2433
}
2534
);
@@ -74,7 +83,7 @@ pub enum WaitStatus {
7483
/// child process. This is only returned if `WaitPidFlag::WNOHANG`
7584
/// was used (otherwise `wait()` or `waitpid()` would block until
7685
/// there was something to report).
77-
StillAlive
86+
StillAlive,
7887
}
7988

8089
impl WaitStatus {
@@ -140,7 +149,7 @@ fn continued(status: i32) -> bool {
140149
unsafe { libc::WIFCONTINUED(status) }
141150
}
142151

143-
fn decode(pid : Pid, status: i32) -> WaitStatus {
152+
fn decode(pid: Pid, status: i32) -> WaitStatus {
144153
if exited(status) {
145154
WaitStatus::Exited(pid, exit_status(status))
146155
} else if signaled(status) {
@@ -178,10 +187,16 @@ pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Re
178187

179188
let option_bits = match options {
180189
Some(bits) => bits.bits(),
181-
None => 0
190+
None => 0,
182191
};
183192

184-
let res = unsafe { libc::waitpid(pid.into().unwrap_or(Pid::from_raw(-1)).into(), &mut status as *mut c_int, option_bits) };
193+
let res = unsafe {
194+
libc::waitpid(
195+
pid.into().unwrap_or(Pid::from_raw(-1)).into(),
196+
&mut status as *mut c_int,
197+
option_bits,
198+
)
199+
};
185200

186201
Ok(match try!(Errno::result(res)) {
187202
0 => StillAlive,

0 commit comments

Comments
 (0)