PID file truncate fix
- on unix it truncated the file if a second instance was being launched
This commit is contained in:
parent
a48dff3bee
commit
623553393b
|
@ -56,7 +56,7 @@ class singleinstance:
|
||||||
pidLine = "%i\n" % self.lockPid
|
pidLine = "%i\n" % self.lockPid
|
||||||
os.write(self.fd, pidLine)
|
os.write(self.fd, pidLine)
|
||||||
else: # non Windows
|
else: # non Windows
|
||||||
self.fp = open(self.lockfile, 'w')
|
self.fp = open(self.lockfile, 'a+')
|
||||||
try:
|
try:
|
||||||
if self.daemon and self.lockPid != os.getpid():
|
if self.daemon and self.lockPid != os.getpid():
|
||||||
fcntl.lockf(self.fp, fcntl.LOCK_EX) # wait for parent to finish
|
fcntl.lockf(self.fp, fcntl.LOCK_EX) # wait for parent to finish
|
||||||
|
@ -68,6 +68,7 @@ class singleinstance:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
pidLine = "%i\n" % self.lockPid
|
pidLine = "%i\n" % self.lockPid
|
||||||
|
self.fp.truncate(0)
|
||||||
self.fp.write(pidLine)
|
self.fp.write(pidLine)
|
||||||
self.fp.flush()
|
self.fp.flush()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user