Enum nix::sys::wait::WaitStatus[][src]

pub enum WaitStatus {
    Exited(Pidi32),
    Signaled(PidSignalbool),
    Stopped(PidSignal),
    PtraceEvent(PidSignalc_int),
    PtraceSyscall(Pid),
    Continued(Pid),
    StillAlive,
}
Expand description

Possible return values from wait() or waitpid().

Each status (other than StillAlive) describes a state transition in a child process Pid, such as the process exiting or stopping, plus additional data about the transition if any.

Note that there are two Linux-specific enum variants, PtraceEvent and PtraceSyscall. Portable code should avoid exhaustively matching on WaitStatus.

Variants

Exited(Pidi32)

Tuple Fields

0: Pid
1: i32

The process exited normally (as with exit() or returning from main) with the given exit code. This case matches the C macro WIFEXITED(status); the second field is WEXITSTATUS(status).

Signaled(PidSignalbool)

Tuple Fields

0: Pid
1: Signal
2: bool

The process was killed by the given signal. The third field indicates whether the signal generated a core dump. This case matches the C macro WIFSIGNALED(status); the last two fields correspond to WTERMSIG(status) and WCOREDUMP(status).

Stopped(PidSignal)

Tuple Fields

0: Pid
1: Signal

The process is alive, but was stopped by the given signal. This is only reported if WaitPidFlag::WUNTRACED was passed. This case matches the C macro WIFSTOPPED(status); the second field is WSTOPSIG(status).

PtraceEvent(PidSignalc_int)

Tuple Fields

0: Pid
1: Signal
2: c_int

The traced process was stopped by a PTRACE_EVENT_* event. See nix::sys::ptrace and ptrace(2) for more information. All currently-defined events use SIGTRAP as the signal; the third field is the PTRACE_EVENT_* value of the event.

PtraceSyscall(Pid)

Tuple Fields

0: Pid

The traced process was stopped by execution of a system call, and PTRACE_O_TRACESYSGOOD is in effect. See ptrace(2) for more information.

Continued(Pid)

Tuple Fields

0: Pid

The process was previously stopped but has resumed execution after receiving a SIGCONT signal. This is only reported if WaitPidFlag::WCONTINUED was passed. This case matches the C macro WIFCONTINUED(status).

StillAlive

There are currently no state changes to report in any awaited child process. This is only returned if WaitPidFlag::WNOHANG was used (otherwise wait() or waitpid() would block until there was something to report).

Implementations

Extracts the PID from the WaitStatus unless it equals StillAlive.

Convert a raw wstatus as returned by waitpid/wait into a WaitStatus

Errors

Returns an Error corresponding to EINVAL for invalid status values.

Examples

Convert a wstatus obtained from libc::waitpid into a WaitStatus:

use nix::sys::wait::WaitStatus;
use nix::sys::signal::Signal;
let pid = nix::unistd::Pid::from_raw(1);
let status = WaitStatus::from_raw(pid, 0x0002);
assert_eq!(status, Ok(WaitStatus::Signaled(pid, Signal::SIGINT, false)));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.