Enum WaitState

Source
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.

Fields

§exit_code: ExitCode

The exit code of the process.

§

Signaled

Indicates that the process was terminated by a signal, with an optional core dump.

Fields

§signal: Signal

The signal that caused the termination.

§core_dump: bool

Whether a core dump occurred.

§

Unsupported(i32)

Indicates a wait status code that is not recognized or supported.

Implementations§

Source§

impl WaitState

Source

pub const fn from_raw(status: i32) -> Self

Creates a new UnixWaitIf from the underlying i32 status code.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for WaitState

Source§

fn clone(&self) -> WaitState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WaitState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<i32> for WaitState

Source§

fn from(status: i32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for WaitState

Source§

fn eq(&self, other: &WaitState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for WaitState

Source§

impl Eq for WaitState

Source§

impl StructuralPartialEq for WaitState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.