pub enum WaitStatus {
Exited(Pid, i32),
Signaled(Pid, Signal, bool),
Stopped(Pid, Signal),
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(Pid, 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(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 to WTERMSIG(status)
and WCOREDUMP(status)
.
Stopped(Pid, 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)
.
Continued(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§
Source§impl WaitStatus
impl WaitStatus
Source§impl WaitStatus
impl WaitStatus
Sourcepub fn from_raw(pid: Pid, status: i32) -> Result<WaitStatus>
pub fn from_raw(pid: Pid, status: i32) -> Result<WaitStatus>
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§
Source§impl Clone for WaitStatus
impl Clone for WaitStatus
Source§fn clone(&self) -> WaitStatus
fn clone(&self) -> WaitStatus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for WaitStatus
impl Debug for WaitStatus
Source§impl Hash for WaitStatus
impl Hash for WaitStatus
Source§impl PartialEq for WaitStatus
impl PartialEq for WaitStatus
impl Copy for WaitStatus
impl Eq for WaitStatus
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)