Skip to content

Commit 8f2468c

Browse files
committed
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.
2 parents 31d242e + ecd0954 commit 8f2468c

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/sys/wait.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,31 @@ libc_bitflags!(
88
pub struct WaitPidFlag: c_int {
99
WNOHANG;
1010
WUNTRACED;
11+
#[cfg(any(target_os = "android",
12+
target_os = "freebsd",
13+
target_os = "haiku",
14+
target_os = "ios",
15+
target_os = "linux",
16+
target_os = "macos",
17+
target_os = "netbsd"))]
1118
WEXITED;
1219
WCONTINUED;
20+
#[cfg(any(target_os = "android",
21+
target_os = "freebsd",
22+
target_os = "haiku",
23+
target_os = "ios",
24+
target_os = "linux",
25+
target_os = "macos",
26+
target_os = "netbsd"))]
1327
WSTOPPED;
1428
/// Don't reap, just poll status.
29+
#[cfg(any(target_os = "android",
30+
target_os = "freebsd",
31+
target_os = "haiku",
32+
target_os = "ios",
33+
target_os = "linux",
34+
target_os = "macos",
35+
target_os = "netbsd"))]
1536
WNOWAIT;
1637
/// Don't wait on children of other threads in this group
1738
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -74,7 +95,7 @@ pub enum WaitStatus {
7495
/// child process. This is only returned if `WaitPidFlag::WNOHANG`
7596
/// was used (otherwise `wait()` or `waitpid()` would block until
7697
/// there was something to report).
77-
StillAlive
98+
StillAlive,
7899
}
79100

80101
impl WaitStatus {
@@ -140,7 +161,7 @@ fn continued(status: i32) -> bool {
140161
unsafe { libc::WIFCONTINUED(status) }
141162
}
142163

143-
fn decode(pid : Pid, status: i32) -> WaitStatus {
164+
fn decode(pid: Pid, status: i32) -> WaitStatus {
144165
if exited(status) {
145166
WaitStatus::Exited(pid, exit_status(status))
146167
} else if signaled(status) {
@@ -178,10 +199,16 @@ pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Re
178199

179200
let option_bits = match options {
180201
Some(bits) => bits.bits(),
181-
None => 0
202+
None => 0,
182203
};
183204

184-
let res = unsafe { libc::waitpid(pid.into().unwrap_or(Pid::from_raw(-1)).into(), &mut status as *mut c_int, option_bits) };
205+
let res = unsafe {
206+
libc::waitpid(
207+
pid.into().unwrap_or(Pid::from_raw(-1)).into(),
208+
&mut status as *mut c_int,
209+
option_bits,
210+
)
211+
};
185212

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

0 commit comments

Comments
 (0)