From c46a93e290194cdeb1b4e1776d4bf0edde303072 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 25 Jun 2014 12:36:25 -0300 Subject: Add SIGINT handler. --- src/leap/bitmask/app.py | 4 ++++ src/leap/bitmask/frontend_app.py | 22 +++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 9afe41be..eda4073c 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -41,6 +41,7 @@ # (thanks to: http://www.glassgiant.com/ascii/) import multiprocessing import os +import signal import sys from leap.bitmask.backend.utils import generate_certificates @@ -112,6 +113,9 @@ def start_app(): """ Starts the main event loop and launches the main window. """ + # Ensure that the application quits using CTRL-C + signal.signal(signal.SIGINT, signal.SIG_DFL) + # Parse arguments and store them opts = leap_argparse.get_options() do_display_version(opts) diff --git a/src/leap/bitmask/frontend_app.py b/src/leap/bitmask/frontend_app.py index 12703518..60f20e3c 100644 --- a/src/leap/bitmask/frontend_app.py +++ b/src/leap/bitmask/frontend_app.py @@ -18,8 +18,6 @@ import signal import sys import os -from functools import partial - from PySide import QtCore, QtGui from leap.bitmask.config import flags @@ -41,18 +39,6 @@ def sigint_handler(*args, **kwargs): mainwindow.quit() -def sigterm_handler(*args, **kwargs): - """ - Signal handler for SIGTERM. - This handler is actually passed to twisted reactor - """ - logger = kwargs.get('logger', None) - if logger: - logger.debug("SIGTERM catched. shutting down...") - mainwindow = args[0] - mainwindow.quit() - - def run_frontend(options): """ Run the GUI for the application. @@ -88,10 +74,12 @@ def run_frontend(options): qApp.setApplicationName("leap") qApp.setOrganizationDomain("leap.se") - window = MainWindow(start_hidden=start_hidden) + MainWindow(start_hidden=start_hidden) - sigint_window = partial(sigint_handler, window, logger=logger) - signal.signal(signal.SIGINT, sigint_window) + # sigint_window = partial(sigint_handler, window, logger=logger) + # signal.signal(signal.SIGINT, sigint_window) + # Ensure that the application quits using CTRL-C + signal.signal(signal.SIGINT, signal.SIG_DFL) sys.exit(qApp.exec_()) -- cgit v1.2.3