File tree Expand file tree Collapse file tree
src/emc/usr_intf/gmoccapy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040from common import hal_glib # needed to make our own hal pins
4141import sys # handle system calls
4242import os # needed to get the paths and directories
43+ import signal # clean shutdown on SIGTERM/SIGINT
4344import atexit # needed to register child's to be closed on closing the GUI
4445import subprocess # to launch onboard and other processes
4546import tempfile # needed only if the user click new in edit mode to open a new empty file
@@ -6594,6 +6595,18 @@ def _make_hal_pins(self):
65946595 raise SystemExit (res )
65956596
65966597
6598+ # Exit on SIGTERM/SIGINT whether or not a main loop is running.
6599+ # Gtk.main_quit() does nothing outside a running loop, so quit the
6600+ # loop if one is active, otherwise exit the process.
6601+ def _terminate (signum , frame ):
6602+ LOG .info ("gmoccapy received signal {}, shutting down" .format (signum ))
6603+ if Gtk .main_level () > 0 :
6604+ Gtk .main_quit ()
6605+ else :
6606+ sys .exit (0 )
6607+ signal .signal (signal .SIGTERM , _terminate )
6608+ signal .signal (signal .SIGINT , _terminate )
6609+
65976610 # start the event loop
65986611 Gtk .main ()
65996612
You can’t perform that action at this time.
0 commit comments