Skip to content

Commit 71e9d6c

Browse files
committed
OS X: add various process status tests defined by wait.h
1 parent 8025a3e commit 71e9d6c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,30 @@ pub const RTLD_NODELETE: ::c_int = 0x80;
10251025
pub const RTLD_NOLOAD: ::c_int = 0x10;
10261026
pub const RTLD_GLOBAL: ::c_int = 0x8;
10271027

1028+
pub const _WSTOPPED: ::c_int = 0o177;
1029+
1030+
f! {
1031+
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
1032+
status >> 8
1033+
}
1034+
1035+
pub fn WSTATUS(status: ::c_int) -> ::c_int {
1036+
status & 0x7f
1037+
}
1038+
1039+
pub fn WIFCONTINUED(status: ::c_int) -> bool {
1040+
WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13
1041+
}
1042+
1043+
pub fn WIFSIGNALED(status: ::c_int) -> bool {
1044+
WSTATUS(status) != _WSTOPPED && WSTATUS(status) != 0
1045+
}
1046+
1047+
pub fn WIFSTOPPED(status: ::c_int) -> bool {
1048+
WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13
1049+
}
1050+
}
1051+
10281052
extern {
10291053
pub fn getnameinfo(sa: *const ::sockaddr,
10301054
salen: ::socklen_t,

src/unix/bsd/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ f! {
330330
pub fn WTERMSIG(status: ::c_int) -> ::c_int {
331331
status & 0o177
332332
}
333+
334+
pub fn WCOREDUMP(status: ::c_int) -> bool {
335+
(status & 0o200) != 0
336+
}
337+
333338
}
334339

335340
extern {

0 commit comments

Comments
 (0)