.context("open /dev/null");
mdup2(null_fd, 0, "null onto stdin");
- let (st_rfd, st_wfd) = pipe().context("pipe");
+ let (st_rfd, st_wfd) = compat::pipe().context("pipe");
match fork().context("fork (1)") {
ForkResult::Child => { }
+#![allow(unused_imports)]
+use std::os::fd::IntoRawFd;
use cfg_if::cfg_if;
use crate::prelude::*;
buf,
)
}
+
+/// Version of [`nix::unistd::pipe`] with a fixed type for the fd
+//
+/// * nix <=0.27 returns a pair of `c_int`
+/// * nix >=0.28 returns a pair of `OwnedFd`
+pub fn pipe() -> nix::Result<(c_int, c_int)> {
+ let (a, b) = nix::unistd::pipe()?;
+ let map = |fd| { cfg_if! {
+ if #[cfg(nix_ge_0_28)] {
+ OwnedFd::into_raw_fd(fd)
+ } else {
+ fd
+ }
+ }};
+ Ok((map(a), map(b)))
+}