From 523ec97cafcaff3090edbe18a1edcb4e615370a0 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 7 Aug 2017 13:47:34 -0700 Subject: [bug] kill a previous process in osx Since in OSX the user sees Bitmask in the Dock, I assume that re-launching Bitmask.app from the /Applications folder means that we can kill the previous process. It probably should be able to terminate it gracefully, but we're hitting this during early testing because of the move to native webview - because the window.close() method is still not properly hooked. - Resolves: #9001 --- src/leap/bitmask/gui/app2.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/leap/bitmask/gui/app2.py b/src/leap/bitmask/gui/app2.py index 13f369c4..f037a000 100644 --- a/src/leap/bitmask/gui/app2.py +++ b/src/leap/bitmask/gui/app2.py @@ -31,17 +31,21 @@ import webbrowser from functools import partial from multiprocessing import Process +import webview +import psutil + from leap.bitmask.core.launcher import run_bitmaskd, pid from leap.common.config import get_path_prefix #from leap.bitmask.gui import app_rc -import webview DEBUG = os.environ.get("DEBUG", False) BITMASK_URI = 'http://localhost:7070/' PIXELATED_URI = 'http://localhost:9090/' +PROCNAME = 'bitmask-app' + qApp = None bitmaskd = None browser = None @@ -114,7 +118,13 @@ def launch_gui(): def start_app(): from leap.bitmask.util import STANDALONE - os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1' + + mypid = os.getpid() + + # Kill a previously-running process + for proc in psutil.process_iter(): + if proc.name() == PROCNAME and proc.pid != mypid: + proc.kill() # Allow the frozen binary in the bundle double as the cli entrypoint # Why have only a user interface when you can have two? -- cgit v1.2.3