pub enum WaitState {
Exited {
exit_code: ExitCode,
},
Signaled {
signal: Signal,
core_dump: bool,
},
Unsupported(i32),
}Expand description
Conditions that interpret a Unix int status returned by waitpid or similar functions.
Provides methods to check the status of a process, such as whether it exited normally, was
terminated by a signal, stopped, or continued, and to retrieve the exit code or signal number
associated with the process’s termination or stopping, without dependence on external crates
such as libc.
Variants§
Exited
Indicates that the process exited normally with a specific exit code.
Signaled
Indicates that the process was terminated by a signal, with an optional core dump.
Fields
Unsupported(i32)
Indicates a wait status code that is not recognized or supported.
Implementations§
Source§impl WaitState
impl WaitState
Sourcepub const fn from_raw(status: i32) -> Self
pub const fn from_raw(status: i32) -> Self
Creates a new UnixWaitIf from the underlying i32 status code.
Sourcepub const fn to_raw(&self) -> i32
pub const fn to_raw(&self) -> i32
Returns a i32 status code that represents the current wait status code.
§Note
It is not guaranteed that the result of this function will be reflexive, meaning that
UnixWaitIf::from_raw(status).to_raw() == status may not always hold true; this function
is provided as a convenience to be able to programatically create a wait status code where
certain conditions are met, i.e. for testing or simulation purposes.
Sourcepub const fn is_w_exited(status: i32) -> bool
pub const fn is_w_exited(status: i32) -> bool
Returns true if the status indicates that the process exited successfully.
Equivalent to the Unix WIFEXITED(status) macro.
Sourcepub const fn w_exit_status(status: i32) -> u8
pub const fn w_exit_status(status: i32) -> u8
Returns the exit code of the process.
Equivalent to the Unix WEXITSTATUS(status) macro.
§Panics
If is_w_exited returns false, this function will panic.
Sourcepub const fn is_w_signaled(status: i32) -> bool
pub const fn is_w_signaled(status: i32) -> bool
Returns true if the status indicates that the process was terminated by a signal.
Equivalent to the Unix WIFSIGNALED(status) macro.
Sourcepub const fn w_term_sig(status: i32) -> u8
pub const fn w_term_sig(status: i32) -> u8
Returns the signal number that caused the process to terminate.
Equivalent to the Unix WTERMSIG(status) macro.
§Panics
If is_w_signaled returns false, this function will panic.
Sourcepub const fn is_w_coredump(status: i32) -> bool
pub const fn is_w_coredump(status: i32) -> bool
Returns true if the status indicates a core dump occurred.
Equivalent to the Unix WCOREDUMP(status) macro.
§Note
Not universally supported across all Unix-like systems; WCOREDUMP is a Linux/BSD
extension, and is checked only if WIFSIGNALED(status) is true.