From 921853677e95f6e129018e8e57956ea5c4ec947d Mon Sep 17 00:00:00 2001 From: syn Date: Thu, 27 Feb 2020 00:06:30 +0300 Subject: Workaround wait4 on MacOS rust's libc does not provide wait4 call on MacOS, so introduce workaround to manually extern it. --- src/wait/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 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>, @@ -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)] { -- cgit v1.2.1-18-gbd029