Open
Description
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
- Implementation: Provide ExitStatusError #82973
- ACP for
Output::exit_ok
Addstd::process::Output::exit_ok
libs-team#554 - Final commenting period (FCP)
- Stabilization PR (including restoring mentions in
ExitStatus
docs) - Add
#[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. - Consider implementing
Try
forExitStatus
Unresolved Questions
- None yet.