add a wrapper around nix::unistd::pipe2
Using O_CLOEXEC by default, and returning Fd handles to ensure they get dropped on bail!() or panic!() if the RawFds aren't used yet. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
897982e237
commit
efd1536eb7
|
@ -677,3 +677,9 @@ impl FromRawFd for Fd {
|
||||||
Self(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)))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue