Skip to content

Conversation

@naoNao89
Copy link
Contributor

Fixes #9127

The bug: child processes inherited ignored signal handlers, breaking trap commands in scripts run under cascaded timeouts.

The fix: reset signal handlers to default before exec(), and properly distinguish timeout signals (exit 124) from external signals (exit 128+N).

@naoNao89 naoNao89 force-pushed the fix-timeout-group-signal-handling branch 2 times, most recently from 0d03cef to 5cde083 Compare November 15, 2025 04:20
Fixes uutils#9127 - cascaded timeouts now properly propagate signals

**Root Cause**
• Child processes inherit signal dispositions from parent
• exec() preserves SIG_IGN, making shell trap handlers fail
• Signals like SIGINT/SIGTERM were ignored in nested timeouts

**Signal Handling Fixes**
• Block signals before spawning child (prevents race conditions)
• Reset handlers to SIG_DFL in pre_exec() for:
  - SIGINT, SIGTERM, SIGHUP, SIGQUIT (shell script signals)
  - SIGTTIN, SIGTTOU (job control signals)
• Install handlers with sigaction() + SA_RESTART (matches GNU)
• Unblock signals after handler installation
• Send signals from handler using async-signal-safe functions

**Exit Code Handling**
• SIGALRM (timeout expired) → exit 124
• External signals (SIGTERM, SIGINT) → exit 128 + signal number
• Tracks received signal to return correct exit code

**Tests Added**
• test_cascaded_timeout_signal_propagation (sh + trap handlers)
• test_cascaded_timeout_with_bash_trap (bash SIGINT handling)

**Other Changes**
• Add #[allow(dead_code)] to Terminated enum variant
• Update cspell dictionary with signal-related terms
@naoNao89 naoNao89 force-pushed the fix-timeout-group-signal-handling branch from 5cde083 to e2cd4a0 Compare November 15, 2025 04:35
@github-actions
Copy link

GNU testsuite comparison:

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

@oech3
Copy link
Contributor

oech3 commented Nov 17, 2025

needs update to avoid no space left on CI

@naoNao89
Copy link
Contributor Author

okee

@naoNao89 naoNao89 force-pushed the fix-timeout-group-signal-handling branch from 91b5a67 to e2cd4a0 Compare November 17, 2025 13:52
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.

GNU coreutils 9.9: Test report

2 participants