mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
697a74b0c1
commit
177998f6a3
@ -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):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user