From 088ccd1ea86c2f0efb34bc26f387f1718f5ad26f Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 9 Nov 2010 14:22:25 +0000 Subject: [PATCH] Fix daemonize problem that surfaced in start_all Thanks to Michael Giarlo for reporting the problem, Bill Erickson for pointing the way to the solution, and http://bugs.python.org/issue5313 for providing me with more context for the problem & solution. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@2061 9efc2488-bf62-4759-914b-345cdb29e865 --- src/python/osrf/system.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/python/osrf/system.py b/src/python/osrf/system.py index 0df4d73..dff93b0 100644 --- a/src/python/osrf/system.py +++ b/src/python/osrf/system.py @@ -101,11 +101,17 @@ class System(object): def daemonize(parentExit=True): pid = os.fork() if pid == 0: - os.chdir('/') - os.setsid() - sys.stdin.close() - sys.stdout.close() - sys.stderr.close() + try: + os.chdir('/') + os.setsid() + sys.stdin.close() + sys.stdin = open(os.devnull) + sys.stdout.close() + sys.stdout = open(os.devnull) + sys.stderr.close() + sys.stderr = open(os.devnull) + except (OSError, ValueError): + pass elif parentExit: os._exit(0) -- 2.43.2