diff options
author | syn <isaqtm@gmail.com> | 2020-02-27 00:06:30 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2020-02-27 00:06:30 +0300 |
commit | 921853677e95f6e129018e8e57956ea5c4ec947d (patch) | |
tree | 8b7bb5123d27a7eda4578079bc3765fa2b8e7a52 | |
parent | 0c2e1910bd05ac7c783f0c815ca44539d9ff557e (diff) | |
download | evr-921853677e95f6e129018e8e57956ea5c4ec947d.tar.gz |
Workaround wait4 on MacOS
rust's libc does not provide wait4 call on MacOS,
so introduce workaround to manually extern it.
-rw-r--r-- | src/wait/mod.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/wait/mod.rs b/src/wait/mod.rs index c591bb1..1a699a0 100644 --- a/src/wait/mod.rs +++ b/src/wait/mod.rs @@ -48,6 +48,21 @@ impl TryFrom<WaitInfo> for ChildExitStatus { } +#[cfg(target_os = "macos")] +#[link(name = "c")] +extern { + fn wait4( + pid: libc::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut libc::rusage + ) -> libc::pid_t; +} + +#[cfg(target_os = "linux")] +use libc::wait4; + + fn wait4_pid( pid: Pid, chan: mpsc::Sender<std::result::Result<WaitInfo, nix::Error>>, @@ -59,7 +74,7 @@ fn wait4_pid( unsafe { usg = std::mem::zeroed(); - wait_ret = libc::wait4(pid.as_raw(), &mut status, 0 as c_int, &mut usg); + wait_ret = wait4(pid.as_raw(), &mut status, 0 as c_int, &mut usg); } #[allow(unused_must_use)] { |