WaitStatus

Struct WaitStatus 

Source
pub struct WaitStatus {
    raw_status: c_int,
}
Expand description

子进程的状态编码(对应 waitpid/wait4 返回的 wstatus)。 包含了解析和构造状态值的方法。

Fields§

§raw_status: c_int

Implementations§

Source§

impl WaitStatus

Source

pub const fn new(raw_status: c_int) -> Self

从原始的 wstatus 整数值创建一个 WaitStatus 实例。

Source

pub const fn raw(&self) -> c_int

获取原始状态值。

Source

pub fn exit_code(ret: u8, sig: u8) -> Self

__W_EXITCODE: 构造一个正常退出或因信号终止的状态值。

结构: (Exit Code) << 8 | (Termination Signal)

  • ret: 退出码 (0-255)
  • sig: 信号编号 (如果为 0 则表示正常退出)
Source

pub fn stop_code(sig: u8) -> Self

__W_STOPCODE: 构造一个子进程被停止的状态值。

结构: (Signal that stopped the child) << 8 | 0x7f

  • sig: 导致停止的信号编号
Source

pub fn continued_code() -> Self

构造一个子进程从停止状态恢复继续执行的状态值。

Source

pub fn termination_signal(&self) -> c_int

如果 WIFSIGNALED 为真,返回导致子进程终止的信号编号(低 7 位)。

Source

pub fn is_exited(&self) -> bool

检查状态是否表示正常终止(即终止信号为 0)。

Source

pub fn exit_status(&self) -> c_int

如果 is_exited() 为真,返回子进程的退出状态码(位于第 8-15 位)。

Source

pub fn is_signaled(&self) -> bool

检查状态是否表示子进程因未捕获的信号而终止。

Source

pub fn is_stopped(&self) -> bool

检查状态是否表示子进程被停止信号停止。

Source

pub fn stop_signal(&self) -> c_int

如果 is_stopped() 为真,返回导致子进程停止的信号编号。 注意:该宏等价于 __WEXITSTATUS(status),即提取第 8-15 位。

Source

pub fn is_continued(&self) -> bool

检查状态是否表示子进程已从停止状态恢复执行。

Source

pub fn did_core_dump(&self) -> bool

检查子进程终止时是否生成了核心转储文件。

Trait Implementations§

Source§

impl Clone for WaitStatus

Source§

fn clone(&self) -> WaitStatus

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for WaitStatus

Source§

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

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

impl PartialEq for WaitStatus

Source§

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

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

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 WaitStatus

Source§

impl Eq for WaitStatus

Source§

impl StructuralPartialEq for WaitStatus

Auto Trait Implementations§

§

impl Freeze for WaitStatus

§

impl RefUnwindSafe for WaitStatus

§

impl Send for WaitStatus

§

impl Sync for WaitStatus

§

impl Unpin for WaitStatus

§

impl UnwindSafe for WaitStatus

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.