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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use crate::imp;
use bitflags::bitflags;
bitflags! {
pub struct WaitOptions: u32 {
const NOHANG = imp::process::WNOHANG as _;
const UNTRACED = imp::process::WUNTRACED as _;
const CONTINUED = imp::process::WCONTINUED as _;
}
}
#[derive(Debug, Clone, Copy)]
pub struct WaitStatus(u32);
impl WaitStatus {
#[inline]
pub(crate) fn new(status: u32) -> Self {
Self(status)
}
#[inline]
pub const fn as_raw(self) -> u32 {
self.0
}
#[inline]
pub fn stopped(self) -> bool {
imp::process::WIFSTOPPED(self.0 as _)
}
#[inline]
pub fn continued(self) -> bool {
imp::process::WIFCONTINUED(self.0 as _)
}
#[inline]
pub fn stopping_signal(self) -> Option<u32> {
if self.stopped() {
Some(imp::process::WSTOPSIG(self.0 as _) as _)
} else {
None
}
}
#[inline]
pub fn exit_status(self) -> Option<u32> {
if imp::process::WIFEXITED(self.0 as _) {
Some(imp::process::WEXITSTATUS(self.0 as _) as _)
} else {
None
}
}
#[inline]
pub fn terminating_signal(self) -> Option<u32> {
if imp::process::WIFSIGNALED(self.0 as _) {
Some(imp::process::WTERMSIG(self.0 as _) as _)
} else {
None
}
}
}