1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

uucore/pipes: adapt to new return type of nix fn

nix 0.28 changed the return type of unistd::pipe() from Result<(RawFd, RawFd), Error> to Result<(OwnedFd, OwnedFd), Error>
This commit is contained in:
Daniel Hofstetter 2024-03-11 16:24:39 +01:00
parent ae7bc7d2e3
commit 15cb0242ea

View file

@ -8,7 +8,6 @@ use std::fs::File;
use std::io::IoSlice; use std::io::IoSlice;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::os::unix::io::FromRawFd;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use nix::fcntl::SpliceFFlags; use nix::fcntl::SpliceFFlags;
@ -21,8 +20,7 @@ pub use nix::{Error, Result};
/// from the first. /// from the first.
pub fn pipe() -> Result<(File, File)> { pub fn pipe() -> Result<(File, File)> {
let (read, write) = nix::unistd::pipe()?; let (read, write) = nix::unistd::pipe()?;
// SAFETY: The file descriptors do not have other owners. Ok((File::from(read), File::from(write)))
unsafe { Ok((File::from_raw_fd(read), File::from_raw_fd(write))) }
} }
/// Less noisy wrapper around [`nix::fcntl::splice`]. /// Less noisy wrapper around [`nix::fcntl::splice`].