Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from common import hal_glib # needed to make our own hal pins
import sys # handle system calls
import os # needed to get the paths and directories
import signal # clean shutdown on SIGTERM/SIGINT
import atexit # needed to register child's to be closed on closing the GUI
import subprocess # to launch onboard and other processes
import tempfile # needed only if the user click new in edit mode to open a new empty file
Expand Down Expand Up @@ -6594,6 +6595,18 @@ def _make_hal_pins(self):
raise SystemExit(res)


# Exit on SIGTERM/SIGINT whether or not a main loop is running.
# Gtk.main_quit() does nothing outside a running loop, so quit the
# loop if one is active, otherwise exit the process.
def _terminate(signum, frame):
LOG.info("gmoccapy received signal {}, shutting down".format(signum))
if Gtk.main_level() > 0:
Gtk.main_quit()
else:
sys.exit(0)
signal.signal(signal.SIGTERM, _terminate)
signal.signal(signal.SIGINT, _terminate)

# start the event loop
Gtk.main()

Loading