1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use bitflags::*;
pub const MAX_SIG: usize = 31;
bitflags! {
pub struct SignalFlags: u32 {
const SIGDEF = 1;
const SIGHUP = 1 << 1;
const SIGINT = 1 << 2;
const SIGQUIT = 1 << 3;
const SIGILL = 1 << 4;
const SIGTRAP = 1 << 5;
const SIGABRT = 1 << 6;
const SIGBUS = 1 << 7;
const SIGFPE = 1 << 8;
const SIGKILL = 1 << 9;
const SIGUSR1 = 1 << 10;
const SIGSEGV = 1 << 11;
const SIGUSR2 = 1 << 12;
const SIGPIPE = 1 << 13;
const SIGALRM = 1 << 14;
const SIGTERM = 1 << 15;
const SIGSTKFLT = 1 << 16;
const SIGCHLD = 1 << 17;
const SIGCONT = 1 << 18;
const SIGSTOP = 1 << 19;
const SIGTSTP = 1 << 20;
const SIGTTIN = 1 << 21;
const SIGTTOU = 1 << 22;
const SIGURG = 1 << 23;
const SIGXCPU = 1 << 24;
const SIGXFSZ = 1 << 25;
const SIGVTALRM = 1 << 26;
const SIGPROF = 1 << 27;
const SIGWINCH = 1 << 28;
const SIGIO = 1 << 29;
const SIGPWR = 1 << 30;
const SIGSYS = 1 << 31;
}
}
impl SignalFlags {
pub fn check_error(&self) -> Option<(i32, &'static str)> {
if self.contains(Self::SIGINT) {
Some((-2, "Killed, SIGINT=2"))
} else if self.contains(Self::SIGILL) {
Some((-4, "Illegal Instruction, SIGILL=4"))
} else if self.contains(Self::SIGABRT) {
Some((-6, "Aborted, SIGABRT=6"))
} else if self.contains(Self::SIGFPE) {
Some((-8, "Erroneous Arithmetic Operation, SIGFPE=8"))
} else if self.contains(Self::SIGKILL) {
Some((-9, "Killed, SIGKILL=9"))
} else if self.contains(Self::SIGSEGV) {
Some((-11, "Segmentation Fault, SIGSEGV=11"))
} else {
None
}
}
}