Skip to content

tee: SIGPIPE not ignored for --output-error/-p modes #10325

@sylvestre

Description

@sylvestre

Component

tee --output-error, tee -p

Description

GNU tee ignores SIGPIPE when --output-error is set (or -p), allowing broken-pipe writes to return EPIPE for in-process handling. uutils only resets SIGPIPE to default when no output_error mode is selected; there is no SIGPIPE ignore path for warn/exit modes.

// src/uu/tee/src/tee.rs:162-166
if options.ignore_interrupts {
    ignore_interrupts().map_err(|_| Error::from(ErrorKind::Other))?;
}
if options.output_error.is_none() {
    enable_pipe_errors().map_err(|_| Error::from(ErrorKind::Other))?;
// No SIG_IGN for output_error modes

GNU explicitly calls signal(SIGPIPE, SIG_IGN) when output_error != output_error_sigpipe.

Test / Reproduction Steps

# Terminal 1:
mkfifo /tmp/testpipe
yes | tee --output-error=warn /tmp/testpipe /tmp/out.txt &
TEE_PID=$!

# Terminal 2:
cat /tmp/testpipe | head -1
# Close the pipe

# Check tee status
wait $TEE_PID; echo $?

# GNU: continues writing to /tmp/out.txt, prints warning, exits normally
# uutils: killed by SIGPIPE (exit 141), /tmp/out.txt truncated

Impact

In pipelines where outputs close early, uutils tee is terminated by SIGPIPE even when the user explicitly requested warn/exit behavior. This skips writes to remaining outputs and yields signal-driven exit status instead of the configured --output-error behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions