Skip to content

Commit 6ad1be7

Browse files
committed
Auto merge of #271 - mbarnett:add_WSIGNALED_etc_for_osx, r=alexcrichton
OS X: add various process status tests defined by wait.h Adds the various process test macros specified in the wait(2) manpage on OS X. ```WCOREDUMP``` is implemented BSD-wide as it seems to be the only macro whose definition is constant across the BSDs.
2 parents 81efe51 + 06abf3a commit 6ad1be7

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
@@ -1026,6 +1026,30 @@ pub const RTLD_NODELETE: ::c_int = 0x80;
10261026
pub const RTLD_NOLOAD: ::c_int = 0x10;
10271027
pub const RTLD_GLOBAL: ::c_int = 0x8;
10281028

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

src/unix/bsd/mod.rs

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

336341
extern {

0 commit comments

Comments
 (0)