--- statusicon.py.orig 2011-02-27 16:24:58.302477337 +0100 +++ statusicon.py 2011-02-27 16:49:21.219144004 +0100 @@ -26,6 +26,7 @@ import sys, os import subprocess, signal import gettext +import atexit import pygtk pygtk.require("2.0") @@ -40,6 +41,14 @@ import utils +def cleanup(process): + try: + process.terminate() + process.wait() + except OSError: + pass # already dead. + + def run(): # Internationalisation gettext.bindtextdomain('redshift', defs.LOCALEDIR) @@ -50,7 +59,7 @@ args = sys.argv[1:] args.insert(0, os.path.join(defs.BINDIR, 'redshift')) process = subprocess.Popen(args) - + try: if appindicator: # Create indicator @@ -127,8 +136,9 @@ def child_cb(pid, cond, data=None): sys.exit(-1) - # Add watch on child process + # Add watch on child process, register cleanup function glib.child_watch_add(process.pid, child_cb) + atexit.register(cleanup, process) # Run main loop gtk.main() @@ -136,8 +146,3 @@ except KeyboardInterrupt: # Ignore user interruption pass - - finally: - # Always terminate redshift - process.terminate() - process.wait()