touchy: exit cleanly on SIGTERM#4077
Open
grandixximo wants to merge 1 commit into
Open
Conversation
touchy ignored SIGTERM (GLib/PyGObject absorbs the signal), so a caller tearing it down had to escalate to SIGKILL. Install a SIGTERM handler that quits the GTK main loop, deferring the quit to the loop via GLib.idle_add since GTK calls are not safe directly from a signal handler. atexit cleanup (child processes, prefs) still runs. This does not touch the interactive window-close path. SIGTERM is a system terminate request and should not require confirmation. Note: PyGObject still prints a benign KeyboardInterrupt on this shutdown; that is pre-existing (touchy printed it on SIGTERM before too, it just did not exit) and is emitted from PyGObject's C layer, so it is not suppressible from Python here. Surfaced by the ui-smoke tests (PR LinuxCNC#4054).
5 tasks
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.
touchy ignored SIGTERM: PyGObject/GLib absorbed it, so the process never exited and the ui-smoke teardown had to escalate to SIGKILL after the grace period.
This installs a SIGTERM handler that requests
Gtk.main_quit()via the idle queue, so the GTK loop unwinds normally and touchy's existing atexit cleanup (child panels, saved prefs) still runs.Known cosmetic wart: PyGObject prints one
KeyboardInterruptline on exit, emitted from its C-level wakeup-fd bridge. It is not suppressible from Python (signal.signal,GLib.unix_signal_add,sys.excepthook,sys.unraisablehookall tried); onlyos._exithides it, which would skip the atexit cleanup. Pre-existing, so no regression.Part of the SIGTERM clean-shutdown work discussed in #4054.