Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile on Darwin #466

Merged
merged 1 commit into from Jul 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/sys/unix.rs
Expand Up @@ -32,7 +32,13 @@ pub fn killpg(pgid: u32, signal: i32) -> io::Result<()> {

pub fn pipe2(flags: usize) -> io::Result<(RawFd, RawFd)> {
let mut fds = [0; 2];

#[cfg(not(target_os = "macos"))]
cvt(unsafe { libc::pipe2(fds.as_mut_ptr(), flags as c_int) })?;

#[cfg(target_os = "macos")]
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;

Ok((fds[0], fds[1]))
}

Expand Down Expand Up @@ -129,7 +135,11 @@ pub mod job_control {
use shell::status::{FAILURE, TERMINATED};
use shell::Shell;
use libc::{self, pid_t};
use nix::sys::wait::{waitpid, WaitStatus, WCONTINUED, WNOHANG, WUNTRACED};

use nix::sys::wait::{waitpid, WaitStatus, WNOHANG, WUNTRACED};
#[cfg(not(target_os = "macos"))]
use nix::sys::wait::{WCONTINUED};

use nix::sys::signal::Signal;
use nix::{Errno, Error};

Expand All @@ -146,7 +156,13 @@ pub mod job_control {
fg_was_grabbed = true;
}
}
match waitpid(-(pid as pid_t), Some(WUNTRACED | WCONTINUED | WNOHANG)) {

#[cfg(not(target_os = "macos"))]
let opts = Some(WUNTRACED | WCONTINUED | WNOHANG);
#[cfg(target_os = "macos")]
let opts = Some(WUNTRACED | WNOHANG);

match waitpid(-(pid as pid_t), opts) {
Ok(WaitStatus::Exited(_, status)) => {
if !fg_was_grabbed {
eprintln!("ion: ([{}] {}) exited with {}", njob, pid, status);
Expand Down