summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/housekeeping.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2018-02-14 00:14:21 +0100
committerKali Kaneko <kali@leap.se>2018-02-15 16:36:51 +0100
commit96ba208a00617c462cbdd2802a3c97bc6ebb28f3 (patch)
tree0211c8d51597b6b27bd8148966591face0821875 /src/leap/bitmask/gui/housekeeping.py
parentc52b9f2356189cd09b5992886dbbda6bd7b60cd3 (diff)
[bug] remove stale pidfile
- Resolves: #9229
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')