Commit 573afbd1 authored by Jakob Hellermann's avatar Jakob Hellermann Committed by Michael Aaron Murphy
Browse files

fix: Split pipe2 into pipe and fcntl on macOS and iOS

Fixes a deprecation warning on these platforms
parent 5d7052ab
......@@ -3,14 +3,24 @@ use super::{
PipelineError,
};
#[cfg(any(target_os = "ios", target_os = "macos"))]
use nix::fcntl::{fcntl, FcntlArg};
use nix::{fcntl::OFlag, unistd};
use std::{fs::File, os::unix::io::FromRawFd};
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
pub fn create_pipe() -> Result<(File, File), PipelineError> {
let (reader, writer) =
unistd::pipe2(OFlag::O_CLOEXEC).map_err(PipelineError::CreatePipeError)?;
Ok(unsafe { (File::from_raw_fd(reader), File::from_raw_fd(writer)) })
}
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub fn create_pipe() -> Result<(File, File), PipelineError> {
let (reader, writer) = unistd::pipe().map_err(PipelineError::CreatePipeError)?;
fcntl(reader, FcntlArg::F_SETFL(OFlag::O_CLOEXEC)).map_err(PipelineError::CreatePipeError)?;
fcntl(writer, FcntlArg::F_SETFL(OFlag::O_CLOEXEC)).map_err(PipelineError::CreatePipeError)?;
Ok(unsafe { (File::from_raw_fd(reader), File::from_raw_fd(writer)) })
}
pub struct TeePipe<'a, 'b> {
parent: &'a mut RefinedJob<'b>,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment