Daemon Windows fix

- closing the filehandle isn't the correct approach, it causes more
bugs. Use os.devnull instead
This commit is contained in:
Peter Šurda 2017-08-20 12:05:53 +02:00
parent 314af0925f
commit b886f935d4
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -351,18 +351,12 @@ class Main:
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()
try: si = file(os.devnull, 'r')
si = file('/dev/null', 'r') so = file(os.devnull, 'a+')
so = file('/dev/null', 'a+') se = file(os.devnull, 'a+', 0)
se = file('/dev/null', 'a+', 0) os.dup2(si.fileno(), sys.stdin.fileno())
os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno())
os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.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): def setSignalHandler(self):
signal.signal(signal.SIGINT, helper_generic.signal_handler) signal.signal(signal.SIGINT, helper_generic.signal_handler)