Skip to content

[4.0.2] Disarm screensaver signal traps before cleanup - #9196

Closed
ryanrhughes wants to merge 2 commits into
v4-0-2from
fix/v4-0-2-screensaver-signal-reentry
Closed

ryanrhughes wants to merge 2 commits into
v4-0-2from
fix/v4-0-2-screensaver-signal-reentry

Conversation

@ryanrhughes

Copy link
Copy Markdown
Collaborator

Summary

Why

omarchy-screensaver can recursively re-enter its SIGHUP handler during terminal teardown until Bash exhausts its stack and segfaults. Installing the no-op traps in the trap command itself closes the pre-function call boundary; installing them at the top of exit_screensaver also protects direct cleanup calls.

This uses trap : rather than an ignored disposition so commands launched during cleanup remain responsive to signals.

Fixes #8386.

Verification

  • test/shell.d/screensaver-signal-test.sh passes for signal-triggered and input-triggered cleanup
  • focused test passed 50 consecutive stress runs
  • mutation test rejects the vulnerable v4-0-2 tree at the cleanup re-entry assertion
  • ./test/cli passes
  • ./test/all reaches and passes the new test; its five unrelated failures reproduce unchanged on pristine origin/v4-0-2 (three require a local omarchy-pkgs checkout, one is the existing theme guard environment leak, and one is the existing live two-monitor IPC duplication)
  • bash -n and git diff --check pass

omarchybot and others added 2 commits August 30, 2026 11:40
exit_screensaver closes the terminal that owns this script's own pty, and bash
re-enters a trap for the signal it is already handling, so every hangup that
teardown sends back nests the handler one level deeper until the stack is gone.

Disarming as the function's first statement is one command too late, because
bash can re-enter at the call boundary before the body starts. Driving the real
script from a pty on an Omarchy 4.0.1-1 worker under a sustained hangup, eight
runs each: the shipped handler segfaulted 8 times, disarming inside the function
2, and disarming as the trap's own first command 0.

trap : rather than trap '' because an ignored disposition survives exec, which
would leave the hyprctl and pkill children immune to SIGTERM too.

Co-Authored-By: Codex GPT-5.6 <codex@openai.com>
@ryanrhughes
ryanrhughes deleted the fix/v4-0-2-screensaver-signal-reentry branch August 30, 2026 15:51
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.

2 participants