Possible fix for --detach crash on some linux systems

Do not use file objects for redirecting the std streams as they could be
garbage collected closing the streams. Also redirect stdin. I dont
really expect either of these to fix the issue, but it's a start.
This commit is contained in:
Kovid Goyal 2014-08-24 00:51:02 +05:30
parent 697a74b0c1
commit 177998f6a3

View File

@ -880,9 +880,10 @@ def detach_gui():
if os.fork() != 0: if os.fork() != 0:
raise SystemExit(0) raise SystemExit(0)
os.setsid() os.setsid()
so, se = file(os.devnull, 'a+'), file(os.devnull, 'a+', 0) si, so, se = os.open(os.devnull, os.O_RDONLY), os.open(os.devnull, os.O_WRONLY), os.open(os.devnull, os.O_WRONLY)
os.dup2(so.fileno(), sys.__stdout__.fileno()) os.dup2(si, sys.__stdin__.fileno())
os.dup2(se.fileno(), sys.__stderr__.fileno()) os.dup2(so, sys.__stdout__.fileno())
os.dup2(se, sys.__stderr__.fileno())
class Application(QApplication): class Application(QApplication):