Feature gate: #![feature(exit_status_error)]
This is a tracking issue for ExitStatusError (and ExitStatus::exit_ok).
This feature makes it convenient to properly check the exit status of subprocesses (such as from Command)
Example
use std::process::Command;
let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err();
assert_eq!(bad.code(), Some(1));
Public API
(In pseudo-syntax:)
impl ExitStatus {
fn exit_ok(self) -> Result<(), ExitStatusError> {..}
}
pub struct ExitStatusError(...); // newtype around a NonZero integer
impl Eq,Copy,Debug,Error,Display for ExitStatusError;
impl Into<ExitStatus> for ExitStatusError;
impl ExitStatusError {
fn code(&self) -> Option<i32> {..} } // WIFEXITED WEXITSTATUS
fn code_nonzero(&self) -> Option<NonZeroi32> {..}
...
}
impl ExitStatusExt for ExitStatusError; // .is_signal() etc.
impl Output {
fn exit_ok(self) -> Result<Self, ExitStatusError>;
}
Steps / History
Unresolved Questions
Feature gate:
#![feature(exit_status_error)]This is a tracking issue for
ExitStatusError(andExitStatus::exit_ok).This feature makes it convenient to properly check the exit status of subprocesses (such as from
Command)Example
Public API
(In pseudo-syntax:)
Steps / History
Output::exit_okAddstd::process::Output::exit_oklibs-team#554ExitStatusdocs)#[must_use]toprocess::ExitStatus(previous attempt Add #[must_use] to process::Command, process::Child and process::ExitStatus #81452); see also Tracking Issue for std::process error handling #73131.TryforExitStatusUnresolved Questions