evobench_tools/utillib/
unix.rs

1// XX I already did something like this somewhere, right?
2
3use std::{os::unix::process::ExitStatusExt, process::ExitStatus};
4
5pub trait ToExitCode {
6    fn to_exit_code(&self) -> i32;
7}
8
9impl ToExitCode for ExitStatus {
10    fn to_exit_code(&self) -> i32 {
11        if self.success() {
12            0
13        } else {
14            self.code()
15                .or_else(|| self.signal().map(|x| x + 128))
16                .unwrap_or(255)
17        }
18    }
19}