Skip to content

Commit 40ad042

Browse files
committed
gmoccapy: exit on SIGTERM received during startup
#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.
1 parent 1d82815 commit 40ad042

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ def excepthook(exc_type, exc_obj, exc_tb):
5959
# caller escalates to SIGKILL.
6060
if issubclass(exc_type, KeyboardInterrupt):
6161
LOG.info("gmoccapy interrupted (signal), shutting down")
62-
try:
62+
if Gtk.main_level() > 0:
6363
Gtk.main_quit()
64-
except Exception:
65-
pass
64+
else:
65+
# Signalled before the main loop starts (e.g. during startup).
66+
# The interrupt was swallowed at the GTK C boundary, so returning
67+
# here just resumes startup; force the exit.
68+
os._exit(0)
6669
return
6770
try:
6871
w = app.widgets.window1

0 commit comments

Comments
 (0)