Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 50a78b5

Browse files
committed
Modified lockfile checking method
Previous check looked to see if there was a lockfile, then if the PID in the lockfile referred to a running process. This created a false positive if, after a reboot, a different process had gotten the PID in the lockfile. The new check looks to see if there's a running instance of btsyncindicator with the PID in the lockfile.
1 parent 845185d commit 50a78b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

btsyncindicator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757

5858
@contextmanager
5959
def file_lock(lock_file):
60+
runningpids = subprocess.check_output("ps aux | grep btsyncindicator | grep -v grep | awk '{print $2}'", shell=True).split()
6061
if os.path.exists(lock_file):
6162
# is it a zombie?
6263
f = open(lock_file, 'r')
6364
pid = f.read()
6465
f.close()
65-
if not os.path.exists('/proc/' + pid):
66+
if pid not in runningpids:
6667
os.remove(lock_file)
6768
else:
6869
print 'Only one indicator can run at once. '\

0 commit comments

Comments
 (0)