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