diff --git a/src/tools.rs b/src/tools.rs index 4da9c491..43a9bfe8 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -677,3 +677,9 @@ impl FromRawFd for Fd { Self(fd) } } + +// wrap nix::unistd::pipe2 + O_CLOEXEC into something returning guarded file descriptors +pub fn pipe() -> Result<(Fd, Fd), Error> { + let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?; + Ok((Fd(pin), Fd(pout))) +}