@@ -40,16 +40,54 @@ libc_bitflags!(
40
40
target_os = "android" ) ) ]
41
41
const WSTOPPED : WaitPidFlag = WUNTRACED ;
42
42
43
+ /// Possible return values from `wait()` or `waitpid()`, indicating a state
44
+ /// transition in a child process. The `Pid` member indicates which
45
+ /// process is reporting the state transition.
46
+ ///
47
+ /// Note that there are two Linux-specific enum variants, `PtraceEvent`
48
+ /// and `PtraceSyscall`. Portable code should avoid exhaustively
49
+ /// matching on `WaitStatus`.
43
50
#[ derive( Eq , PartialEq , Clone , Copy , Debug ) ]
44
51
pub enum WaitStatus {
52
+ /// The process exited normally (as with `exit()` or returning from
53
+ /// `main`) with the given exit code. This case matches the C macro
54
+ /// `WIFEXITED(status)`; the second field is `WEXITSTATUS(status)`.
45
55
Exited ( Pid , i8 ) ,
56
+ /// The process was killed by the given signal. The third field
57
+ /// indicates whether the signal generated a core dump. This case
58
+ /// matches the C macro `WIFSIGNALED(status)`; the last two fields
59
+ /// correspond to `WTERMSIG(status)` and `WCOREDUMP(status)`.
46
60
Signaled ( Pid , Signal , bool ) ,
61
+ /// The process is alive, but was stopped by the given signal. This
62
+ /// is only reported if `WaitPidFlag::WUNTRACED` was passed. This
63
+ /// case matches the C macro `WIFSTOPPED(status)`; the second field
64
+ /// is `WSTOPSIG(status)`.
47
65
Stopped ( Pid , Signal ) ,
66
+ /// The traced process was stopped by a `PTRACE_EVENT_*` event. See
67
+ /// [`nix::sys::ptrace`] and [`ptrace`(2)] for more information. All
68
+ /// currently-defined events use `SIGTRAP` as the signal; the third
69
+ /// field is the `PTRACE_EVENT_*` value of the event.
70
+ ///
71
+ /// [`nix::sys::ptrace`]: ../ptrace/index.html
72
+ /// [`ptrace`(2)]: http://man7.org/linux/man-pages/man2/ptrace.2.html
48
73
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
49
74
PtraceEvent ( Pid , Signal , c_int ) ,
75
+ /// The traced process was stopped by execution of a system call,
76
+ /// and `PTRACE_O_TRACESYSGOOD` is in effect. See [`ptrace`(2)] for
77
+ /// more information.
78
+ ///
79
+ /// [`ptrace`(2)]: http://man7.org/linux/man-pages/man2/ptrace.2.html
50
80
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
51
81
PtraceSyscall ( Pid ) ,
82
+ /// The process was previously stopped but has resumed execution
83
+ /// after receiving a `SIGCONT` signal. This is only reported if
84
+ /// `WaitPidFlag::WCONTINUED` was passed. This case matches the C
85
+ /// macro `WIFCONTINUED(status)`.
52
86
Continued ( Pid ) ,
87
+ /// There are currently no state changes to report in any awaited
88
+ /// child process. This is only returned if `WaitPidFlag::WNOHANG`
89
+ /// was used (otherwise `wait()` or `waitpid()` would block until
90
+ /// there was something to report).
53
91
StillAlive
54
92
}
55
93
0 commit comments