Struct std::process::ExitStatus
Re-export from std::process::unix::ExitStatus
Describes the result of a process after it has terminated.
Methods
impl ExitStatus { ... }
-
fn from_wait_status(wait_status: c_int) -> ExitStatus
Create
ExitStatus
from an wait status (not exit code).Wait status is the return value of functions such as
wait
andwaitpid
. -
fn wait_status(self: &ExitStatus) -> i32
Returns the raw wait status of the process.
Example
use std::process::Command; use std::fs::Path; let command = Command::new(Path::new("/usr/bin/false")); let status = command.spawn().unwrap().wait().unwrap(); assert_eq!(status.wait_status(), 256); // (1 << 8) | 0
Run this example -
fn success(self: &ExitStatus) -> bool
Returns true if process completed successfully
This implies that the process was not terminated by a signal and that the exit code is 0.
Example
use std::process::Command; use std::fs::Path; let command = Command::new(Path::new("/usr/bin/true")); let status = command.spawn().unwrap().wait().unwrap(); assert!(status.success());
Run this example -
fn core_dumped(self: &ExitStatus) -> bool
-
fn code(self: &ExitStatus) -> Option<i32>
Returns exit code of a process, if present.
If the process was terminated by a signal, this will return
Option::none()
(see signal). -
fn signal(self: &ExitStatus) -> Option<i32>
Returns the signal number the process was terminated by.
If the process was not temrinated by a signal, this will return
Option::none()
(see code). -
fn equals(self: &ExitStatus, other: &ExitStatus) -> bool
-
fn hash<H>(self: &ExitStatus, h: &mut H)
H: Hasher<H>
Mixins
impl ExitStatus { ... }
-
mixin Equatable<ExitStatus>
-
Returns
false
if arguments are equal,true
otherwise