kernel_explainer/
signals.rs1pub fn signal_description(num: i32) -> String {
3 match num {
4 15 => {
5 "SIGTERM (15): ask the process to exit cleanly; can be caught or handled.".to_string()
6 }
7 9 => "SIGKILL (9): forcefully kill the process; cannot be caught, blocked, or ignored."
8 .to_string(),
9 2 => "SIGINT (2): interrupt from keyboard (Ctrl-C); default is to terminate.".to_string(),
10 3 => "SIGQUIT (3): quit from keyboard; usually terminates and produces a core dump."
11 .to_string(),
12 1 => "SIGHUP (1): hangup; often used by daemons to reload configuration.".to_string(),
13 19 => "SIGSTOP (19): stop (pause) the process; cannot be caught or ignored.".to_string(),
14 18 => "SIGCONT (18): resume a process previously stopped with SIGSTOP/SIGTSTP.".to_string(),
15 10 => {
16 "SIGUSR1 (10): user-defined signal 1; semantics are application-specific.".to_string()
17 }
18 12 => {
19 "SIGUSR2 (12): user-defined signal 2; semantics are application-specific.".to_string()
20 }
21 other => format!("Signal {}: see `kill -l` for details.", other),
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use super::signal_description;
28
29 #[test]
30 fn describes_common_signals() {
31 let term = signal_description(15);
32 assert!(term.contains("SIGTERM"));
33
34 let kill = signal_description(9);
35 assert!(kill.contains("SIGKILL"));
36 }
37
38 #[test]
39 fn describes_unknown_signal_generically() {
40 let s = signal_description(99);
41 assert!(s.contains("Signal 99"));
42 }
43}