Crate sysexit [−] [src]
This module provides exit codes for programs.
The choice of an appropriate exit value is often ambigeous and whilst it is impossible to provide an authoritative anthology that applies under all circumstances, this module attempts to collect the most frequently recognised exit codes across Unix systems.
Exit statuses fall between 0 and 255 (inclusive), and codes greater than zero indicate failure. The range 125–128 is reserved shell-specific statuses, including shell builtins and compound commands. The range 129–154 is reserved fatal signals, explained below.
Usage:
use std::process; use sysexit; let exit_status = process::Command::new("sh") .arg("-c").arg(format!("exit {}", 65)) .status() .expect("failed to run sh(1)"); let exit_code = sysexit::from_status(exit_status); println!("{}", exit_code);
This outputs:
i/o error (74)
As a basis it encodes the exit codes of sysexits(3) from OpenBSD (64–78), exit statuses used by [bash(1)],
supplemented by codes created by shells when the command is terminated
by a fatal signal. When the fatal signal is a number N, the latter
follows bash’s strategy of using the value 128 + N as the exit status.
This means that the SIGHUP
(1) signal will be recognised as the exit code
for the number 129.
It should be pointed out that numeric exit codes are an absolute abomination, but we are stuck with them.
Reexports
pub use self::Code::*; |
Enums
Code |
A successful exit is always indicated by a status of 0, or
|
Functions
from_status |
Converts |
is_error |
Determines if the provided |
is_reserved |
Tests if the provided exit code is reserved, and has a special meaning in shells. |
is_success |
Determines if the provided |
is_valid |
Test if provided exit code is valid, that is within the 0–255 (inclusive) range. |