diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 2cb8346394..388a8123bd 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -170,7 +170,7 @@ parser-num = ["extendedbigdecimal", "num-traits"] parser-size = ["parser-num", "procfs"] parser-glob = ["glob"] parser = ["parser-num", "parser-size", "parser-glob"] -pipes = [] +pipes = ["fs"] process = ["libc"] proc-info = ["tty", "walkdir"] quoting-style = ["i18n-common"] diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs index 6a90faab8d..cee53393d7 100644 --- a/src/uucore/src/lib/features/pipes.rs +++ b/src/uucore/src/lib/features/pipes.rs @@ -139,12 +139,12 @@ where // If the first splice manages to copy to the intermediate // pipe, but the second splice to stdout fails for some reason // we can recover by copying the data that we have from the - // intermediate pipe to stdout using normal read/write. Then + // intermediate pipe to stdout using unbuffered read/write. Then // we tell the caller to fall back. debug_assert!(n <= MAX_ROOTLESS_PIPE_SIZE, "unexpected RAM usage"); let mut drain = Vec::with_capacity(n); pipe_rd.take(n as u64).read_to_end(&mut drain)?; - dest.write_all(&drain)?; + crate::io::write_all_raw(dest, &drain)?; return Ok(true); } } @@ -210,9 +210,10 @@ pub fn send_n_bytes( } } else { debug_assert!(s <= MAX_ROOTLESS_PIPE_SIZE, "unexpected RAM usage"); + // drain pipe before fallback to raw write let mut drain = Vec::with_capacity(s); broker_r.take(s as u64).read_to_end(&mut drain)?; - target.write_all(&drain)?; + crate::io::write_all_raw(&target, &drain)?; break true; } }