Only write PID after last fork
- should fix systemd integration
This commit is contained in:
parent
6fb5a751c6
commit
3cb9547389
|
@ -363,7 +363,7 @@ class Main:
|
||||||
# fork not implemented
|
# fork not implemented
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
shared.thisapp.lock() # relock
|
shared.thisapp.lock(True) # relock and write pid
|
||||||
shared.thisapp.lockPid = None # indicate we're the final child
|
shared.thisapp.lockPid = None # indicate we're the final child
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class singleinstance:
|
||||||
self.initialized = True
|
self.initialized = True
|
||||||
atexit.register(self.cleanup)
|
atexit.register(self.cleanup)
|
||||||
|
|
||||||
def lock(self):
|
def lock(self, writePid = False):
|
||||||
if self.lockPid is None:
|
if self.lockPid is None:
|
||||||
self.lockPid = os.getpid()
|
self.lockPid = os.getpid()
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
|
@ -68,9 +68,10 @@ class singleinstance:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
pidLine = "%i\n" % self.lockPid
|
pidLine = "%i\n" % self.lockPid
|
||||||
self.fp.truncate(0)
|
if writePid:
|
||||||
self.fp.write(pidLine)
|
self.fp.truncate(0)
|
||||||
self.fp.flush()
|
self.fp.write(pidLine)
|
||||||
|
self.fp.flush()
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if not self.initialized:
|
if not self.initialized:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user