Skip to content

gmoccapy: exit on SIGTERM/SIGINT regardless of main-loop state#4115

Merged
BsAtHome merged 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gmoccapy-sigterm-robust
Jun 4, 2026
Merged

gmoccapy: exit on SIGTERM/SIGINT regardless of main-loop state#4115
BsAtHome merged 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gmoccapy-sigterm-robust

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

gmoccapy did not reliably exit on SIGTERM; callers had to escalate to SIGKILL.

#4076 routed the signal through excepthook to Gtk.main_quit(), but that only quits while Gtk.main() is iterating. A signal arriving during startup, or while a nested dialog is up, hits gtk_main_quit: assertion 'main_loops != NULL' and gmoccapy keeps running.

This installs an explicit SIGTERM/SIGINT handler that quits the loop if one is active, otherwise exits the process. Surfaced by the ui-smoke quit-path tests (#4054).

The KeyboardInterrupt-via-excepthook path only quits while Gtk.main()
is iterating; a signal during startup or a nested dialog hits
'gtk_main_quit: assertion main_loops != NULL' and gmoccapy runs on
until SIGKILL. Install an explicit handler that quits the loop if one
runs, else exits the process.
@grandixximo
Copy link
Copy Markdown
Contributor Author

@andypugh need merge this too, then the smoke test phase 2 should pass, I think 🤔

@grandixximo
Copy link
Copy Markdown
Contributor Author

@BsAtHome when you have a moment, could you take a look at this one? It is the gmoccapy half of the SIGTERM cleanup; #4076 only quits while the Gtk main loop is iterating, so a signal during startup or a nested dialog hits gtk_main_quit: assertion 'main_loops != NULL' and the process runs on until SIGKILL. This adds an explicit handler that exits regardless of loop state. It is the last fix blocking the ui-smoke phase-2 quit tests in #4054.

@BsAtHome BsAtHome merged commit 91e27c6 into LinuxCNC:master Jun 4, 2026
15 checks passed
grandixximo added a commit to grandixximo/linuxcnc that referenced this pull request Jun 4, 2026
LinuxCNC#4115 installs the signal handler just before Gtk.main(), so a SIGTERM
arriving during construction is still handled by the excepthook via
KeyboardInterrupt. With no main loop running, Gtk.main_quit() asserts
and the interrupt is swallowed at the GTK C boundary, so the process
runs on until SIGKILL. Force the exit when no loop is active.
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