From ca693798c3ed3d9193dbea713ca4927b6d6d0279 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Aug 2014 01:46:45 +0530 Subject: [PATCH] ... --- src/calibre/gui2/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 17ef7e8801..01fe406c0f 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -874,16 +874,19 @@ def setup_gui_option_parser(parser): parser.add_option('--detach', default=False, action='store_true', help=_('Detach from the controlling terminal, if any (linux only)')) +def do_detach(): + # Detach from the controlling process. + if os.fork() != 0: + raise SystemExit(0) + os.setsid() + try: + plugins['speedup'][0].detach(os.devnull) + except AttributeError: + pass # people running from source without updated binaries + def detach_gui(): if islinux and not DEBUG: - # Detach from the controlling process. - if os.fork() != 0: - raise SystemExit(0) - os.setsid() - try: - plugins['speedup'][0].detach(os.devnull) - except AttributeError: - pass # people running from source without updated binaries + do_detach() class Application(QApplication):