Skip to content

Conversation

@ChrisDryden
Copy link
Collaborator

@ChrisDryden ChrisDryden commented Jan 19, 2026

Instead of adding this code to every utility, hoping to make it centralized and then addressing all of the special cases in the individual utilities. There's definitely a chance that a special case is missed and could be a regression, but this should solve a much larger number of issues for all utilities.

Fixes #10325
Fixes #10260
Fixes #10230
Fixes #10214
Fixes #9936
Fixes #8919
Fixes #7252
Fixes #4965

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

CodSpeed Performance Report

Merging this PR will improve performance by 3.85%

Comparing ChrisDryden:sigpipe-main-macro (847fff3) with main (cbbff30)

Summary

⚡ 1 improved benchmark
✅ 141 untouched benchmarks
⏩ 180 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation sort_ascii_utf8_locale 18.1 ms 17.5 ms +3.85%

Footnotes

  1. 180 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes SIGPIPE handling across all uutils utilities by moving the signal setup logic into the #[uucore::main] procedural macro. Previously, each utility had to manually call enable_pipe_errors() to restore SIGPIPE's default behavior. Now this happens automatically in the macro, with utilities only needing to opt-out when they require special SIGPIPE handling.

Changes:

  • Centralized SIGPIPE capture and restoration in the #[uucore::main] proc macro
  • Added disable_pipe_errors() function for utilities that need to override default SIGPIPE behavior
  • Removed redundant SIGPIPE setup code from 7 utilities (yes, tr, timeout, tail, seq, env, cat)
  • Added special SIGPIPE handling for 3 utilities with non-standard requirements (tee, tty, split)

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/uucore_procs/src/lib.rs Added SIGPIPE state capture at module level and restoration logic before user code executes in the main macro
src/uucore/src/lib/features/signals.rs Added disable_pipe_errors() function and updated documentation for enable_pipe_errors()
src/uucore/Cargo.toml Added "signals" feature to default features to enable SIGPIPE handling for all utilities
src/uu/yes/src/yes.rs Removed redundant enable_pipe_errors() call now handled by macro
src/uu/tty/src/tty.rs Added disable_pipe_errors() to handle broken pipes gracefully and exit with code 3
src/uu/tr/src/tr.rs Removed redundant SIGPIPE setup now handled by macro
src/uu/timeout/src/timeout.rs Removed redundant enable_pipe_errors() call now handled by macro
src/uu/tee/src/tee.rs Changed logic from enable_pipe_errors() when no output-error to disable_pipe_errors() when output-error is set
src/uu/tail/src/tail.rs Removed redundant SIGPIPE setup now handled by macro
src/uu/split/src/split.rs Added conditional disable_pipe_errors() when using --filter option to handle child process stdin closing
src/uu/seq/src/seq.rs Removed manual SIGPIPE capture and restoration now handled by macro
src/uu/env/src/env.rs Removed redundant enable_pipe_errors() call now handled by macro
src/uu/cat/src/cat.rs Removed redundant SIGPIPE setup now handled by macro

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Ecordonnier
Copy link
Collaborator

@ChrisDryden this is a good change. I'm OK to merge it. Can you please fix the conflict?

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@Ecordonnier
Copy link
Collaborator

I think the best way to do this is to use the "Fixes" syntax, then github automatically closes the issues when the PR is merged.

@Ecordonnier Ecordonnier merged commit 376d5b2 into uutils:main Jan 21, 2026
175 of 176 checks passed
mattsu2020 pushed a commit to mattsu2020/coreutils that referenced this pull request Jan 21, 2026
Instead of adding this code to every utility, hoping to make it centralized and then addressing all of the special cases in the individual utilities. There's definitely a chance that a special case is missed and could be a regression, but this should solve a much larger number of issues for all utilities.

Fixes uutils#10325
Fixes uutils#10260
Fixes uutils#10230
Fixes uutils#10214
Fixes uutils#9936
Fixes uutils#8919
Fixes uutils#7252
Fixes uutils#4965
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment