Track when GUI processes are detached

This commit is contained in:
Kovid Goyal 2014-11-15 09:14:28 +05:30
parent 7e0be5825e
commit 8291e02f12

View File

@ -14,7 +14,10 @@ import os, sys
# launch all the GUI apps, forking before Qt is loaded and not during a
# python import.
is_detached = False
def do_detach(fork=True, setsid=True, redirect=True):
global is_detached
if fork:
# Detach from the controlling process.
if os.fork() != 0:
@ -23,10 +26,8 @@ def do_detach(fork=True, setsid=True, redirect=True):
os.setsid()
if redirect:
from calibre.constants import plugins
try:
plugins['speedup'][0].detach(os.devnull)
except AttributeError:
pass # people running from source without updated binaries
plugins['speedup'][0].detach(os.devnull)
is_detached = True
def detach_gui():
from calibre.constants import islinux, isbsd, DEBUG