exit_code.rs
This file
Path
src/util/exit_code.rs
22 lines · 743 bytes · Rust
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 2c174d4 point at it.
Bump serde from 1.0.163 to 1.0.164dependabot[bot]before adoption2c174d4
lines 1–22why, one step back1use std::process::ExitStatus;23#[cfg(unix)]4pub fn extract_exit_code(status: ExitStatus) -> Option<i32> {5 use std::os::unix::process::ExitStatusExt;67 // From the ExitStatus::code documentation:8 //9 // "On Unix, this will return None if the process was terminated by a signal."10 //11 // In that case, ExitStatusExt::signal should never return None.12 //13 // To differentiate between "normal" exit codes and signals, we are using a technique14 // similar to bash (https://tldp.org/LDP/abs/html/exitcodes.html) and add 128 to the15 // signal value.16 status.code().or_else(|| status.signal().map(|s| s + 128))17}1819#[cfg(not(unix))]20pub fn extract_exit_code(status: ExitStatus) -> Option<i32> {21 status.code()22}