Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/uu/tee/src/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
const BUF_SIZE: usize = 32 * 1024;
#[cfg(all(unix, not(target_os = "fuchsia")))]
if uucore::signals::stdin_was_closed() {
let e = Error::from(rustix::io::Errno::BADF);

Check warning on line 152 in src/uu/tee/src/tee.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'BADF' (file:'src/uu/tee/src/tee.rs', line:152)
show_error!(
"{}",
translate!("tee-error-stdin", "error" => strip_errno(&e))
Expand All @@ -160,10 +160,25 @@
let input = rustix::stdio::stdin();
#[cfg(not(any(unix, target_os = "wasi")))]
let mut input = io::stdin();
// needs 2 pipes to duplicate input multiple times
// freeze by max size since system allocates pipe smaller than default size when user has pages more than fs.pipe-user-pages-soft
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Ok((mut pipe_read, mut pipe_write)) = uucore::pipes::pipe::<true>()
// use trivial splice for one writer.
if let [writer] = &mut self.writers[..] {
match uucore::pipes::splice_unbounded_auto(&input, writer) {
Ok(Ok(())) => return Ok(()),
Ok(Err(())) => {} // no splice support
Err(e) => {
return process_error(
self.output_error_mode,
e.into(),
writer,
&mut self.ignored_errors,
)
.map_err(|_| ());
}
}
// needs 2 pipes to duplicate input multiple times
// freeze pipe size since system allocates different sizes when fs.pipe-user-pages-soft was changed between 2 pipe generations
} else if let Ok((mut pipe_read, mut pipe_write)) = uucore::pipes::pipe::<true>()
&& let Ok((mut pipe2_read, mut pipe2_write)) = uucore::pipes::pipe::<true>()
{
use uucore::pipes::MAX_ROOTLESS_PIPE_SIZE;
Expand Down
Loading