From 314af0925f0514ce84f297877f4347bd1d767668 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 20 Aug 2017 11:55:54 +0200 Subject: [PATCH] Daemonize fix for Windows - /dev/null isn't available on Windows so just close the console sockets directly --- src/bitmessagemain.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 426af695..62e79371 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -351,12 +351,18 @@ class Main: shared.thisapp.lockPid = None # indicate we're the final child sys.stdout.flush() sys.stderr.flush() - si = file('/dev/null', 'r') - so = file('/dev/null', 'a+') - se = file('/dev/null', 'a+', 0) - os.dup2(si.fileno(), sys.stdin.fileno()) - os.dup2(so.fileno(), sys.stdout.fileno()) - os.dup2(se.fileno(), sys.stderr.fileno()) + try: + si = file('/dev/null', 'r') + so = file('/dev/null', 'a+') + se = file('/dev/null', 'a+', 0) + os.dup2(si.fileno(), sys.stdin.fileno()) + os.dup2(so.fileno(), sys.stdout.fileno()) + os.dup2(se.fileno(), sys.stderr.fileno()) + # /dev/null not available + except IOError: + sys.stdin.close() + sys.stdout.close() + sys.stderr.close() def setSignalHandler(self): signal.signal(signal.SIGINT, helper_generic.signal_handler)