From cd8f6757b51a8eedc3e29c22656ade1ae22110fe Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Mon, 14 Jul 2014 12:08:37 -0300 Subject: Apply changes removed rebasing pullreq #679. https://github.com/leapcode/bitmask_client/pull/679/files --- src/leap/bitmask/frontend_app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/leap/bitmask/frontend_app.py b/src/leap/bitmask/frontend_app.py index ffcb61ad..51607d0b 100644 --- a/src/leap/bitmask/frontend_app.py +++ b/src/leap/bitmask/frontend_app.py @@ -27,7 +27,6 @@ from functools import partial from PySide import QtCore, QtGui from leap.bitmask.config import flags -from leap.bitmask.gui import locale_rc # noqa - silence pylint from leap.bitmask.gui.mainwindow import MainWindow from leap.bitmask.util import dict_to_flags @@ -35,20 +34,24 @@ import logging logger = logging.getLogger(__name__) -def signal_handler(window, signum, frame): +def signal_handler(window, pid, signum, frame): """ Signal handler that quits the running app cleanly. :param window: a window with a `quit` callable :type window: MainWindow + :param pid: process id of the main process. + :type pid: int :param signum: number of the signal received (e.g. SIGINT -> 2) :type signum: int :param frame: current stack frame :type frame: frame or None """ - pname = multiprocessing.current_process().name - logger.debug("{0}: SIGNAL #{1} catched.".format(pname, signum)) - window.quit() + my_pid = os.getpid() + if pid == my_pid: + pname = multiprocessing.current_process().name + logger.debug("{0}: SIGNAL #{1} catched.".format(pname, signum)) + window.quit() def run_frontend(options, flags_dict): @@ -101,7 +104,8 @@ def run_frontend(options, flags_dict): window = MainWindow(start_hidden=start_hidden) - sig_handler = partial(signal_handler, window) + my_pid = os.getpid() + sig_handler = partial(signal_handler, window, my_pid) signal.signal(signal.SIGINT, sig_handler) signal.signal(signal.SIGTERM, sig_handler) -- cgit v1.2.3