summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/app.py2
-rw-r--r--src/leap/bitmask/frontend_app.py4
-rw-r--r--src/leap/bitmask/gui/mainwindow.py21
3 files changed, 22 insertions, 5 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py
index 88f6bc15..ab49ee37 100644
--- a/src/leap/bitmask/app.py
+++ b/src/leap/bitmask/app.py
@@ -185,7 +185,7 @@ def start_app():
backend_process.daemon = True
backend_process.start()
- run_frontend(options, flags_dict)
+ run_frontend(options, flags_dict, backend_pid=backend_process.pid)
if __name__ == "__main__":
diff --git a/src/leap/bitmask/frontend_app.py b/src/leap/bitmask/frontend_app.py
index 51607d0b..5ea89fc9 100644
--- a/src/leap/bitmask/frontend_app.py
+++ b/src/leap/bitmask/frontend_app.py
@@ -54,7 +54,7 @@ def signal_handler(window, pid, signum, frame):
window.quit()
-def run_frontend(options, flags_dict):
+def run_frontend(options, flags_dict, backend_pid):
"""
Run the GUI for the application.
@@ -102,7 +102,7 @@ def run_frontend(options, flags_dict):
timer.start(500) # You may change this if you wish.
timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms.
- window = MainWindow(start_hidden=start_hidden)
+ window = MainWindow(start_hidden=start_hidden, backend_pid=backend_pid)
my_pid = os.getpid()
sig_handler = partial(signal_handler, window, my_pid)
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index a15c4dd8..59a65b1e 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -22,6 +22,8 @@ import time
from datetime import datetime
+import psutil
+
from PySide import QtCore, QtGui
from leap.bitmask import __version__ as VERSION
@@ -97,7 +99,7 @@ class MainWindow(QtGui.QMainWindow):
# We give the services some time to a halt before forcing quit.
SERVICES_STOP_TIMEOUT = 20000 # in milliseconds
- def __init__(self, start_hidden=False):
+ def __init__(self, start_hidden=False, backend_pid=None):
"""
Constructor for the client main window
@@ -272,6 +274,7 @@ class MainWindow(QtGui.QMainWindow):
self._logger_window = None
self._start_hidden = start_hidden
+ self._backend_pid = backend_pid
self._mail_conductor = mail_conductor.MailConductor(self._backend)
self._mail_conductor.connect_mail_signals(self._mail_status)
@@ -1819,6 +1822,15 @@ class MainWindow(QtGui.QMainWindow):
# or if we reach the timeout
QtDelayedCall(self.SERVICES_STOP_TIMEOUT, self.final_quit)
+ def _backend_kill(self):
+ """
+ Send a kill signal to the backend process.
+ This is called if the backend does not respond to requests.
+ """
+ if self._backend_pid is not None:
+ logger.debug("Killing backend")
+ psutil.Process(self._backend_pid).kill()
+
@QtCore.Slot()
def _remove_service(self, service):
"""
@@ -1854,7 +1866,12 @@ class MainWindow(QtGui.QMainWindow):
logger.debug('Final quit...')
self._leap_signaler.stop()
- self._backend.stop()
+
+ if self._backend.online:
+ self._backend.stop()
+ else:
+ self._backend_kill()
+
time.sleep(0.05) # give the thread a little time to finish.
# Remove lockfiles on a clean shutdown.