Skip to content

Commit 631da86

Browse files
committed
Add W_EXITCODE to construct an exit code
On Linux, `sys/wait.h` defines a `W_EXITCODE` macro to construct an exit code from a return value and a signal number. Provide an equivalent function.
1 parent ab3c229 commit 631da86

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/unix/linux_like/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,10 @@ f! {
12541254
(status & 0x80) != 0
12551255
}
12561256

1257+
pub fn W_EXITCODE(ret: ::c_int, sig: ::c_int) -> ::c_int {
1258+
(ret << 8) | sig
1259+
}
1260+
12571261
pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
12581262
(cmd << 8) | (type_ & 0x00ff)
12591263
}

0 commit comments

Comments
 (0)