Fix daemonize for Windows

Fixes #1034
This commit is contained in:
Peter Šurda 2017-07-28 08:54:34 +02:00
parent a29f7534ee
commit 20cbac9752
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -316,13 +316,23 @@ class Main:
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect') BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
def daemonize(self): def daemonize(self):
try:
if os.fork(): if os.fork():
exit(0) exit(0)
except AttributeError:
# fork not implemented
pass
else:
shared.thisapp.lock() # relock shared.thisapp.lock() # relock
os.umask(0) os.umask(0)
os.setsid() os.setsid()
try:
if os.fork(): if os.fork():
exit(0) exit(0)
except AttributeError:
# fork not implemented
pass
else:
shared.thisapp.lock() # relock shared.thisapp.lock() # relock
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()