Skip to content

touchy: exit cleanly on SIGTERM#4077

Open
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/touchy-sigterm-clean-exit
Open

touchy: exit cleanly on SIGTERM#4077
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/touchy-sigterm-clean-exit

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

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 KeyboardInterrupt line 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.unraisablehook all tried); only os._exit hides it, which would skip the atexit cleanup. Pre-existing, so no regression.

Part of the SIGTERM clean-shutdown work discussed in #4054.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants