This reminds me that I suggested a redesign of ExitStatus
back in 2017: Mini-pre-RFC: Redesigning `process::ExitStatus` It doesn't put a distinction between successful and unsuccessful exit into the type system, but I do like that idea. Perhaps start with
pub enum ExitStatus {
SuccessfulExit,
UnsuccessfulExit(NonZeroI32),
FatalSignal(i32)
}
where the FatalSignal
case never gets used on Windows. It's supposed to be possible to pass an arbitrary i32
value through exit
and recover it in the parent with waitid
, so abstractly we can't pack it down any further, even though I'm not aware of any Unix that actually implements that particular POSIX requirement (see the old thread for gory details).