1use bitflags::*;
2
3bitflags! {
4 pub struct SignalFlags: u32 {
5 const SIGINT = 1 << 2;
6 const SIGILL = 1 << 4;
7 const SIGABRT = 1 << 6;
8 const SIGFPE = 1 << 8;
9 const SIGSEGV = 1 << 11;
10 }
11}
12
13impl SignalFlags {
14 pub fn check_error(&self) -> Option<(i32, &'static str)> {
15 if self.contains(Self::SIGINT) {
16 Some((-2, "Killed, SIGINT=2"))
17 } else if self.contains(Self::SIGILL) {
18 Some((-4, "Illegal Instruction, SIGILL=4"))
19 } else if self.contains(Self::SIGABRT) {
20 Some((-6, "Aborted, SIGABRT=6"))
21 } else if self.contains(Self::SIGFPE) {
22 Some((-8, "Erroneous Arithmetic Operation, SIGFPE=8"))
23 } else if self.contains(Self::SIGSEGV) {
24 Some((-11, "Segmentation Fault, SIGSEGV=11"))
25 } else {
26 None
27 }
28 }
29}