diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 2d45af90c06c04e01de4485c41e8aec51655ebfe..f1be322b7cdcc2f5f9cb548e19f882668e4920d5 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -685,6 +685,20 @@ pub const TIOCSWINSZ: ::c_ulong = 0x80087467; pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +f! { + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + #[link(name = "util")] extern { pub fn getnameinfo(sa: *const ::sockaddr, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d60bbc58bf74464db2b59d1eb484c2dff2e8f494..214edebd30d6a57bccb61e0260d16b62ecfd6075 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -324,18 +324,18 @@ f! { } } + pub fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0o177 + } + pub fn WIFEXITED(status: ::c_int) -> bool { - (status & 0x7f) == 0 + (status & 0o177) == 0 } pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { status >> 8 } - pub fn WTERMSIG(status: ::c_int) -> ::c_int { - status & 0o177 - } - pub fn WCOREDUMP(status: ::c_int) -> bool { (status & 0o200) != 0 } diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index f8ac09d226df8f9c619f7236af541558dbaa8837..72a712cf40b25d914d44af4553dc29bfcc4fb808 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -449,6 +449,20 @@ pub const HW_NCPU: ::c_int = 3; pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +f! { + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + #[link(name = "util")] extern { pub fn mincore(addr: *mut ::c_void, len: ::size_t, diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 5ee8aa1e5ef3008e11bf51876d1df557465902c3..8792e3c8df7d53eb1de16c5db657c8b186b13bd9 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -682,17 +682,33 @@ f! { } } - pub fn WIFEXITED(status: ::c_int) -> bool { - (status & 0xff) == 0 + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f } - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { (status >> 8) & 0xff } + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0x7f) + 1 >= 2 + } + pub fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0x7f } + + pub fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } } extern {