Skip to content

Commit 5a3522f

Browse files
committed
PtraveEvent Documentation
1 parent 98ad58a commit 5a3522f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/sys/wait.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ use sys::signal::Signal;
77
libc_bitflags!(
88
/// Defines optional flags for the `waitpid` function.
99
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.
1112
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
1316
WUNTRACED,
1417
#[cfg(any(target_os = "linux",
1518
target_os = "android"))]
1619
/// Waits for children that have terminated.
1720
WEXITED,
1821
#[cfg(any(target_os = "linux",
1922
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.
2125
WCONTINUED,
2226
#[cfg(any(target_os = "linux",
2327
target_os = "android"))]
@@ -51,11 +55,15 @@ const WSTOPPED: WaitPidFlag = WUNTRACED;
5155
pub enum WaitStatus {
5256
/// Signifies that the process has exited, providing the PID and associated exit status.
5357
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.
5560
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.
5763
Stopped(Pid, Signal),
5864
#[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.
5967
PtraceEvent(Pid, Signal, c_int),
6068
/// Signifies that the process received a `SIGCONT` signal, and thus continued.
6169
Continued(Pid),
@@ -207,11 +215,12 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
207215
cfg_if! {
208216
if #[cfg(any(target_os = "linux", target_os = "android"))] {
209217
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)
213222
} else {
214-
WaitStatus::PtraceEvent(pid, status::stop_signal(status), status::stop_additional(status))
223+
WaitStatus::PtraceEvent(pid, signal, status)
215224
}
216225
}
217226
} else {

0 commit comments

Comments
 (0)