Enum WaitStatus
pub enum WaitStatus
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(Pid, i32) The process exited normally (as with
exit()or returning frommain) with the given exit code. This case matches the C macroWIFEXITED(status); the second field isWEXITSTATUS(status).-
Signaled(Pid, Signal, 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 toWTERMSIG(status)andWCOREDUMP(status).-
Stopped(Pid, Signal) The process is alive, but was stopped by the given signal. This is only reported if
WaitPidFlag::WUNTRACEDwas passed. This case matches the C macroWIFSTOPPED(status); the second field isWSTOPSIG(status).-
PtraceEvent(Pid, Signal, c_int) The traced process was stopped by a
PTRACE_EVENT_*event. Seenix::sys::ptraceandptrace(2) for more information. All currently-defined events useSIGTRAPas the signal; the third field is thePTRACE_EVENT_*value of the event.-
PtraceSyscall(Pid) The traced process was stopped by execution of a system call, and
PTRACE_O_TRACESYSGOODis in effect. Seeptrace(2) for more information.-
Continued(Pid) The process was previously stopped but has resumed execution after receiving a
SIGCONTsignal. This is only reported ifWaitPidFlag::WCONTINUEDwas passed. This case matches the C macroWIFCONTINUED(status).-
StillAlive There are currently no state changes to report in any awaited child process. This is only returned if
WaitPidFlag::WNOHANGwas used (otherwisewait()orwaitpid()would block until there was something to report).
Implementations
impl WaitStatus
fn pid(&self) -> Option<Pid>Extracts the PID from the WaitStatus unless it equals StillAlive.
impl WaitStatus
fn from_raw(pid: Pid, status: i32) -> Result<WaitStatus>Convert a raw
wstatusas returned bywaitpid/waitinto aWaitStatusErrors
Returns an
Errorcorresponding toEINVALfor invalid status values.Examples
Convert a
wstatusobtained fromlibc::waitpidinto aWaitStatus:use WaitStatus; use Signal; let pid = from_raw; let status = from_raw; assert_eq!;
Trait Implementations
impl Clone for WaitStatus
fn clone(&self) -> Self
impl Copy for WaitStatus
impl Debug for WaitStatus
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for WaitStatus
impl Hash for WaitStatus
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for WaitStatus
fn eq(&self, other: &Self) -> bool
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 UnsafeUnpin for WaitStatus
impl UnwindSafe for WaitStatus
Blanket Implementations
impl<T> Any for WaitStatus
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WaitStatus
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WaitStatus
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for WaitStatus
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for WaitStatus
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for WaitStatus
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for WaitStatus
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WaitStatus
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for WaitStatus
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>