Repository navigation
Shut a tray run down through OnStop on SIGTERM and Ctrl+C [patch] - #52
Merged
Merged
Conversation
Only the console path installed signal handlers, and Avalonia handles neither signal, so a tray run sent SIGTERM (kill, systemctl stop, logout) or SIGINT died to the runtime's default handler: the tool's OnStop never ran, and a toggle clicked inside the 500 ms debounce window was never saved. RunTray now takes both, as ConsoleRunner does, and posts the same lifetime shutdown the Quit item asks for, so the run ends through OnExit, Dispose, OnStop and the preference flush and exits 0. scripts/check-tray-signals.sh drives this under Xvfb with a status-notifier watcher: it clicks the remembered toggle, signals inside the debounce window, and fails on a non-zero exit or a lost toggle. Fixes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017UuQscGFrjteUf9Ui3jWdd
…sted RunTray only runs with a real tray, so the handlers written inline there were covered by nothing but the Xvfb script. ShutdownSignals now holds the CancelKeyPress hook and the SIGTERM registration, and decides from the host whether to take the signal; TrayApplication.RequestShutdown reports whether it posted the shutdown. Both are exercised directly in ShutdownSignalsTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017UuQscGFrjteUf9Ui3jWdd
|
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #21
What was wrong
Only
ConsoleRunnerinstalled signal handlers, and Avalonia handles neither signal. So a tray run sentSIGTERM(kill,systemctl stop, logout) orSIGINT(Ctrl+C in the launching terminal) died to the runtime's default handler:OnStopnever ran;That contradicted the README and the
OnStopXML docs.Change
ShutdownSignals, whichRunTrayholds for the length of the run:Console.CancelKeyPressand registersPosixSignalRegistrationforSIGTERM, mirroringConsoleRunner.TrayApplication.RequestShutdown()posts the existingShutdownto the UI thread. That is the path the Quit item and the--fortimer already take, so the run ends throughOnExit→Dispose→OnStop→ theFinishAsyncflush, and exits 0. Only the first request posts anything, so a second Ctrl+C, or a signal during a Quit, doesn't shut down twice.ShutdownSignalsTestscall the handlers directly, with no display. They cover:scripts/check-tray-signals.shis the end-to-end regression check, documented inCLAUDE.mdunder Testing.Runningtoggle.Verification
Run on Linux under
dbus-run-session+ Xvfb:Terminated)"Toggles": {})"Toggles": {})"running": false)"running": false)scripts/check-tray-signals.shfails on the base commit (SIGTERM: exited 143 instead of shutting down) and passes with this change.Not covered here:
ConsoleRunneralready makes on those platforms, but the tray path was only exercised on Linux.🤖 Generated with Claude Code
https://claude.ai/code/session_017UuQscGFrjteUf9Ui3jWdd