OK this is presumably a hard one, I\'ve got an pyGTK application that has random crashes due to X Window errors that I can\'t catch/control.
So I created a wrapper t
You forgot to close gtk's event loop.
This code exits with code 0 when you close the window:
import gtk
class Test(gtk.Window):
def destroy_event(self, widget, data=None):
gtk.main_quit()
def __init__(self):
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
self.connect("destroy", self.destroy_event)
self.show()
f = Test()
gtk.main()
EDIT: Here's the code to catch the SIGTERM signal:
import signal
def handler(signum, frame):
print 'Signal handler called with signal', signum
print 'Finalizing main loop'
gtk.main_quit()
signal.signal(signal.SIGTERM, handler)
The rest of the code is exactly as above, no changes. It works here when I send SIGTERM to the python process: gtk main loop ends and program exits with exit code 0.