From 623553393b640cb459262053bd73cd3ddc320810 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 15 Aug 2017 12:25:38 +0200 Subject: [PATCH] PID file truncate fix - on unix it truncated the file if a second instance was being launched --- src/singleinstance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index 78a0cb33..7a025945 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -56,7 +56,7 @@ class singleinstance: pidLine = "%i\n" % self.lockPid os.write(self.fd, pidLine) else: # non Windows - self.fp = open(self.lockfile, 'w') + self.fp = open(self.lockfile, 'a+') try: if self.daemon and self.lockPid != os.getpid(): fcntl.lockf(self.fp, fcntl.LOCK_EX) # wait for parent to finish @@ -68,6 +68,7 @@ class singleinstance: sys.exit(-1) else: pidLine = "%i\n" % self.lockPid + self.fp.truncate(0) self.fp.write(pidLine) self.fp.flush()