diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-16 14:20:18 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-16 14:20:18 +0200 |
commit | 1a6bf40d199a59a03f3f008402e0865fb1b9fc85 (patch) | |
tree | 46667891902e44365ff5cb9d02811a2d46c1d4ad | |
parent | 061a2eb7ddc6e19740561225010b7c202bfdd4d7 (diff) | |
download | portato-1a6bf40d199a59a03f3f008402e0865fb1b9fc85.tar.gz portato-1a6bf40d199a59a03f3f008402e0865fb1b9fc85.tar.bz2 portato-1a6bf40d199a59a03f3f008402e0865fb1b9fc85.zip |
Abort the main process if child dies.
Diffstat (limited to '')
-rwxr-xr-x | portato.py | 12 | ||||
-rw-r--r-- | portato/plistener.py | 1 |
2 files changed, 12 insertions, 1 deletions
@@ -14,13 +14,20 @@ from __future__ import with_statement, absolute_import +import signal import sys, os, subprocess import gettext, locale from optparse import OptionParser, SUPPRESS_HELP from portato import get_listener +from portato.helper import debug, info from portato.constants import VERSION, LOCALE_DIR, APP, SU_COMMAND +def sigchld_aborter (signal, frame): + """Aborts the current process when the child dies.""" + debug("Child process died. Trying to abort.") + raise KeyboardInterrupt + def main (): # set gettext stuff locale.setlocale(locale.LC_ALL, '') @@ -44,7 +51,6 @@ def main (): if options.nofork or os.getuid() == 0: # start GUI from portato.gui import run - from portato.helper import info info("%s v. %s", _("Starting Portato"), VERSION) if options.shm: @@ -67,7 +73,11 @@ def main (): env.update(DBUS_SESSION_BUS_ADDRESS="") cmd = SU_COMMAND.split() subprocess.Popen(cmd+["%s --no-fork --shm %ld %ld %ld" % (sys.argv[0], mem.key, sig.key, rw.key)], env = env) + + # set handler to abort the listener if needed + signal.signal(signal.SIGCHLD, sigchld_aborter) + # stast listener get_listener().set_recv(mem, sig, rw) if __name__ == "__main__": diff --git a/portato/plistener.py b/portato/plistener.py index 8d35ece..a45a17e 100644 --- a/portato/plistener.py +++ b/portato/plistener.py @@ -56,6 +56,7 @@ class PListener (object): elif data[0] == "close": break except KeyboardInterrupt: + debug("Got KeyboardInterrupt. Aborting.") break self._mem.remove() |