From 20cbac9752b103465064081f72fc8e038e9dfcdb Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 28 Jul 2017 08:54:34 +0200 Subject: [PATCH] Fix daemonize for Windows Fixes #1034 --- src/bitmessagemain.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 3e0a1c84..50c138a2 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -316,14 +316,24 @@ class Main: BMConfigParser().remove_option('bitmessagesettings', 'dontconnect') def daemonize(self): - if os.fork(): - exit(0) - shared.thisapp.lock() # relock + try: + if os.fork(): + exit(0) + except AttributeError: + # fork not implemented + pass + else: + shared.thisapp.lock() # relock os.umask(0) os.setsid() - if os.fork(): - exit(0) - shared.thisapp.lock() # relock + try: + if os.fork(): + exit(0) + except AttributeError: + # fork not implemented + pass + else: + shared.thisapp.lock() # relock shared.thisapp.lockPid = None # indicate we're the final child sys.stdout.flush() sys.stderr.flush()