@@ -8,10 +8,31 @@ libc_bitflags!(
8
8
pub struct WaitPidFlag: c_int {
9
9
WNOHANG;
10
10
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"))]
11
18
WEXITED;
12
19
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"))]
13
27
WSTOPPED;
14
28
/// 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"))]
15
36
WNOWAIT;
16
37
/// Don't wait on children of other threads in this group
17
38
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -74,7 +95,7 @@ pub enum WaitStatus {
74
95
/// child process. This is only returned if `WaitPidFlag::WNOHANG`
75
96
/// was used (otherwise `wait()` or `waitpid()` would block until
76
97
/// there was something to report).
77
- StillAlive
98
+ StillAlive,
78
99
}
79
100
80
101
impl WaitStatus {
@@ -140,7 +161,7 @@ fn continued(status: i32) -> bool {
140
161
unsafe { libc::WIFCONTINUED(status) }
141
162
}
142
163
143
- fn decode(pid : Pid, status: i32) -> WaitStatus {
164
+ fn decode(pid: Pid, status: i32) -> WaitStatus {
144
165
if exited(status) {
145
166
WaitStatus::Exited(pid, exit_status(status))
146
167
} else if signaled(status) {
@@ -178,10 +199,16 @@ pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Re
178
199
179
200
let option_bits = match options {
180
201
Some(bits) => bits.bits(),
181
- None => 0
202
+ None => 0,
182
203
};
183
204
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
+ };
185
212
186
213
Ok(match try!(Errno::result(res)) {
187
214
0 => StillAlive,
0 commit comments