Skip to main content

get_exit_code

Function get_exit_code 

Source
pub fn get_exit_code(signal_name: &str) -> Option<i32>
Expand description

Get the exit code for a signal on the current platform.

Exit codes follow the POSIX 128+N pattern where N is the platform-specific signal number. For SIGUSR1/SIGUSR2, this returns different values on macOS/FreeBSD (158/159) vs Linux (138/140).

ยงExample

use rsfulmen::foundry::signals::get_exit_code;

assert_eq!(get_exit_code("SIGTERM"), Some(143));
assert_eq!(get_exit_code("SIGINT"), Some(130));

// SIGUSR1 exit code varies by platform
let usr1_exit = get_exit_code("SIGUSR1").unwrap();
#[cfg(target_os = "linux")]
assert_eq!(usr1_exit, 138); // 128 + 10
#[cfg(target_os = "macos")]
assert_eq!(usr1_exit, 158); // 128 + 30