Skip to content

fix(timeout): handle SIGTTIN and other signals in the waiting loop to avoid stalling - #13603

Open
Alonely0 wants to merge 7 commits into
uutils:mainfrom
Alonely0:fix-timeout-strace
Open

Alonely0 wants to merge 7 commits into
uutils:mainfrom
Alonely0:fix-timeout-strace

Conversation

@Alonely0

@Alonely0 Alonely0 commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Previously, the waiting loop would not handle SIGTTIN, SIGTTOU, and other signals; this was observed on commands that intercepted them on timeout if the child process required them for termination (or other behaviors). For example, it would hang on strace when the child was cat or tee, same as when trapping them on a subshell.

Note that this old behavior matched our implementation before the backend changes of my previous PR. Now that we have fine-grained control on signal handling, we can trivially match GNU and resolve the linked issue.

The new behavior matches GNU by continuing to wait on terminal job-control signals and forwarding the others on demand.

Fixes: #12979

@codspeed

codspeed Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 118 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 401 untouched benchmarks
⏩ 70 skipped benchmarks1


Comparing Alonely0:fix-timeout-strace (cefdd78) with main (1d6ca65)2

Open in CodSpeed

Footnotes

  1. 70 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. ↩

  2. No successful run was found on main (24f90f5) during the generation of this report, so 1d6ca65 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)

@Alonely0
Alonely0 force-pushed the fix-timeout-strace branch 11 times, most recently from 2500857 to f8f3e0a Compare July 30, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Updates timeout’s Unix signal-wait behavior to avoid stalling when terminal job-control signals are received, aligning behavior more closely with GNU timeout and addressing #12979.

Changes:

  • Treat SIGTTIN/SIGTTOU as “continue waiting” signals in the wait loop.
  • Expand the signal set used by timeout to include additional signals.
  • Add a Unix-only regression test intended to cover terminal job-control signal handling.
File Description
tests/​by-util/​test_timeout.rs Adds a new Unix-only test exercising timeout behavior under SIGTTIN trapping.
src/​uucore/​src/​lib/​features/​process/​unix.rs Updates wait-loop signal handling and expands the timeout signal set.

Review effort: Lite

Comment thread src/uucore/src/lib/features/process/unix.rs Outdated
Comment thread tests/by-util/test_timeout.rs
Copilot AI balanced review requested due to automatic review settings October 25, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
2 resolved since last review

Review effort: Lite

Comment thread tests/by-util/test_timeout.rs Outdated
Copilot AI balanced review requested due to automatic review settings October 25, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
1 resolved since last review

Review effort: Lite

Comment thread src/uucore/src/lib/features/process/unix.rs
Comment thread tests/by-util/test_timeout.rs
Comment on lines +564 to +566
ts.cmd("/bin/sh")
.arg("-c")
.arg(format!("trap 'echo' SIGTTIN; {bin:?} {name} 2 /bin/cat"))

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(timeout): failure to exit on strace when due to SIGTTIN interactions with child process

2 participants