Skip to content

Run the screensaver exit handler exactly once - #9042

Open
PyRo1121 wants to merge 1 commit into
omacom:quattrofrom
PyRo1121:fix/issue-8985
Open

PyRo1121 wants to merge 1 commit into
omacom:quattrofrom
PyRo1121:fix/issue-8985

Conversation

@PyRo1121

@PyRo1121 PyRo1121 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8985

exit_screensaver pkills the parent terminal (its command line carries the screensaver class), and the dying terminal signals the script back. With the trap still armed, that echo re-entered the handler — nesting until bash overflowed its stack (~63,500 frames, SIGSEGV).

The handler now silences SIGINT/SIGTERM/SIGHUP/SIGQUIT before signalling other screensaver processes, so the cleanup restores the cursor, stops ttfx, and exits exactly once.

Tests:

  • bash test/shell.d/screensaver-exit-test.sh — dismisses a stubbed screensaver whose cleanup echoes a SIGHUP back (the way a dying terminal does) and asserts the cursor is restored exactly once and the script exits 0; it fails on the unpatched handler
  • bash -n bin/omarchy-screensaver test/shell.d/screensaver-exit-test.sh
  • git diff --check

Fixes #8386

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 39e34c4 and verified on a disposable Omarchy worker (Ghostty 1.3.1, bash 5.3.15, Hyprland 0.56.2) with a screensaver on each of two monitors.

The bug is real, and this fixes it. I added one line to exit_screensaver that logs each entry, then closed one screensaver window from the compositor (the trigger in #8985). On current quattro, one script re-entered the handler 6, 7, 10, 19 and 34 levels deep across five runs. That is the same nesting the core dumps in #8985 and #8386 show, stopped short of the stack only by timing. With this pull request, every script ran its handler exactly once in all five runs. Window close, SIGHUP to the script and SIGINT to the script all exited cleanly and restored the cursor.

Tests: screensaver-exit-test.sh fails on quattro and passes on this head, three runs each. ./test/cli, bin-style-test.sh and the new test pass on the head. On current quattro with this change applied, idle-test.sh, screensaver-workspace-test.sh, screensaver-exit-test.sh and bin-style-test.sh pass too. ./test/cli fails one vscode theme check there, but it fails identically on quattro without the change, so it is unrelated. GitHub reports no CI for this pull request.

The change is the size of the problem: one line in the handler and a regression test. I linked #8386 too, an earlier report of the same recursion. #6813 rewrites this script's shutdown more broadly and would remove the same re-entry. The two conflict, and which to land is the maintainer's call.

Second opinion: none. Classification was agreed earlier by deepseek-v4p1-flash, but the code review by Codex Medium did not run: the reviewer is reachable, and today's review budget was spent. This review is one model's, Claude Opus 5.5. The pull request carries verified but not ready. It waits on a second opinion on a later run, then on the maintainer.

@omarchybot

Copy link
Copy Markdown
Collaborator

This pull request no longer has anything to fix on quattro. fdbe182 ("Launch the native Wayland screensaver") deleted bin/omarchy-screensaver and replaced the terminal screensaver with the native omarchy-screensaver package, which omarchy-launch-screensaver now execs directly. That is why GitHub shows a conflict: this branch modifies a file quattro has removed. The bash exit_screensaver trap that re-entered itself when the dying terminal sent SIGHUP back went with that file, and the new test would fail on quattro because it runs the deleted script.

What was checked: the conflict (git merge-tree against quattro at d367a56), the history of bin/omarchy-screensaver, and a search of quattro for any other bash handler that kills its own terminal and gets signalled back. None was found. Codex Medium, as the second opinion, read the same source and history on its own and came to the same verdict: obsolete, with nothing left that needs this fix. Independence between the two reviews is not guaranteed. Nothing was run, because there is no longer any code for it to run against.

The fix was right for the screensaver it targeted. My earlier verification on a worker showed that, and #8386 was a real crash. Thank you @PyRo1121 for tracking it down. It is now with the maintainer, with a recommendation to close this pull request and #8386 as fixed by the native screensaver.

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

Labels

bug Something isn't working

Projects

None yet

2 participants