From b886f935d465eb8dd42537117746185556dc83c7 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 20 Aug 2017 12:05:53 +0200 Subject: [PATCH] Daemon Windows fix - closing the filehandle isn't the correct approach, it causes more bugs. Use os.devnull instead --- src/bitmessagemain.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 62e79371..894c9e08 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -351,18 +351,12 @@ class Main: shared.thisapp.lockPid = None # indicate we're the final child sys.stdout.flush() sys.stderr.flush() - 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() + si = file(os.devnull, 'r') + so = file(os.devnull, 'a+') + se = file(os.devnull, 'a+', 0) + os.dup2(si.fileno(), sys.stdin.fileno()) + os.dup2(so.fileno(), sys.stdout.fileno()) + os.dup2(se.fileno(), sys.stderr.fileno()) def setSignalHandler(self): signal.signal(signal.SIGINT, helper_generic.signal_handler)