@@ -7,17 +7,21 @@ use sys::signal::Signal;
7
7
libc_bitflags ! (
8
8
/// Defines optional flags for the `waitpid` function.
9
9
pub flags WaitPidFlag : c_int {
10
- /// Returns immediately if no child has exited
10
+ /// Do not suspend execution of the calling thread if the status is not immediately
11
+ /// available for one of the child processes specified by pid.
11
12
WNOHANG ,
12
- /// Returns if a child has been stopped, but isn't being traced by ptrace.
13
+ /// The status of any child processes specified by pid that are stopped, and whose status
14
+ /// has not yet been reported since they stopped, shall also be reported to the requesting
15
+ /// process
13
16
WUNTRACED ,
14
17
#[ cfg( any( target_os = "linux" ,
15
18
target_os = "android" ) ) ]
16
19
/// Waits for children that have terminated.
17
20
WEXITED ,
18
21
#[ cfg( any( target_os = "linux" ,
19
22
target_os = "android" ) ) ]
20
- /// Waits for previously stopped children that have been resumed with `SIGCONT`.
23
+ /// Report the status of any continued child process specified by pid whose status has not
24
+ /// been reported since it continued from a job control stop.
21
25
WCONTINUED ,
22
26
#[ cfg( any( target_os = "linux" ,
23
27
target_os = "android" ) ) ]
@@ -51,11 +55,15 @@ const WSTOPPED: WaitPidFlag = WUNTRACED;
51
55
pub enum WaitStatus {
52
56
/// Signifies that the process has exited, providing the PID and associated exit status.
53
57
Exited ( Pid , i8 ) ,
54
- /// Signifies that the process was killed by a signal, providing the PID and associated signal.
58
+ /// Signifies that the process was killed by a signal, providing the PID, the associated
59
+ /// signal, and a boolean value that is set to `true` when a core dump was produced.
55
60
Signaled ( Pid , Signal , bool ) ,
56
- /// Signifies that the process was stopped by a signal, providing the PID and associated signal.
61
+ /// Signifies that the process was stopped by a signal, providing the PID and associated
62
+ /// signal.
57
63
Stopped ( Pid , Signal ) ,
58
64
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
65
+ /// Signifies that the process was stopped due to a ptrace event, providing the PID, the
66
+ /// associated signal, and an integer that represents the status of the event.
59
67
PtraceEvent ( Pid , Signal , c_int ) ,
60
68
/// Signifies that the process received a `SIGCONT` signal, and thus continued.
61
69
Continued ( Pid ) ,
@@ -207,11 +215,12 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
207
215
cfg_if ! {
208
216
if #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ] {
209
217
fn decode_stopped( pid: Pid , status: i32 ) -> WaitStatus {
210
- let status_additional = status:: stop_additional( status) ;
211
- if status_additional == 0 {
212
- WaitStatus :: Stopped ( pid, status:: stop_signal( status) )
218
+ let status = status:: stop_additional( status) ;
219
+ let signal = status:: stop_signal( status) ;
220
+ if status == 0 {
221
+ WaitStatus :: Stopped ( pid, signal)
213
222
} else {
214
- WaitStatus :: PtraceEvent ( pid, status :: stop_signal ( status ) , status:: stop_additional ( status ) )
223
+ WaitStatus :: PtraceEvent ( pid, signal , status)
215
224
}
216
225
}
217
226
} else {
0 commit comments