Skip to content

Commit dcfc4fb

Browse files
committed
gmoccapy: exit on SIGTERM received during startup
A SIGTERM during construction, before Gtk.main() runs, reaches the excepthook as a KeyboardInterrupt. With no main loop, Gtk.main_quit() asserts and the interrupt is swallowed at the GTK C boundary, so gmoccapy runs on until SIGKILL. Force the exit when no loop is active.
1 parent 91e27c6 commit dcfc4fb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ 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+
# No loop yet (startup): the interrupt is swallowed at the GTK
66+
# C boundary, so returning resumes startup. Force the exit.
67+
os._exit(0)
6668
return
6769
try:
6870
w = app.widgets.window1

0 commit comments

Comments
 (0)