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