Only write PID after last fork

- should fix systemd integration
This commit is contained in:
Peter Šurda 2017-12-21 14:26:51 +01:00
parent 6fb5a751c6
commit 3cb9547389
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 6 additions and 5 deletions

View File

@ -363,7 +363,7 @@ class Main:
# fork not implemented
pass
else:
shared.thisapp.lock() # relock
shared.thisapp.lock(True) # relock and write pid
shared.thisapp.lockPid = None # indicate we're the final child
sys.stdout.flush()
sys.stderr.flush()

View File

@ -36,7 +36,7 @@ class singleinstance:
self.initialized = True
atexit.register(self.cleanup)
def lock(self):
def lock(self, writePid = False):
if self.lockPid is None:
self.lockPid = os.getpid()
if sys.platform == 'win32':
@ -68,6 +68,7 @@ class singleinstance:
sys.exit(-1)
else:
pidLine = "%i\n" % self.lockPid
if writePid:
self.fp.truncate(0)
self.fp.write(pidLine)
self.fp.flush()