summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/housekeeping.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/gui/housekeeping.py')
-rw-r--r--src/leap/bitmask/gui/housekeeping.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/leap/bitmask/gui/housekeeping.py b/src/leap/bitmask/gui/housekeeping.py
index 5c1d8079..b6c29b47 100644
--- a/src/leap/bitmask/gui/housekeeping.py
+++ b/src/leap/bitmask/gui/housekeeping.py
@@ -2,6 +2,8 @@ import os
import signal
import time
+import psutil
+
from leap.common.config import get_path_prefix
@@ -44,6 +46,21 @@ def reset_authtoken():
pass
+def check_stale_pidfile():
+
+ def is_pid_running(pidno):
+ return 1 == len(filter(lambda p: p.pid == int(pidno), psutil.process_iter()))
+
+ pidno = None
+ pidfile = os.path.join(get_path_prefix(), 'leap', 'bitmaskd.pid')
+ if os.path.isfile(pidfile):
+ with open(pidfile, 'r') as pid_fd:
+ pidno = pid_fd.readline().strip()
+ if pidno and pidno.isdigit():
+ if not is_pid_running(pidno):
+ os.unlink(pidfile)
+
+
def cleanup():
print('[bitmask] cleaning up files')
base = os.path.join(get_path_prefix(), 'leap')