[Opensrf-commits] r2061 - trunk/src/python/osrf (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 9 09:22:27 EST 2010


Author: dbs
Date: 2010-11-09 09:22:25 -0500 (Tue, 09 Nov 2010)
New Revision: 2061

Modified:
   trunk/src/python/osrf/system.py
Log:
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.


Modified: trunk/src/python/osrf/system.py
===================================================================
--- trunk/src/python/osrf/system.py	2010-11-09 13:59:55 UTC (rev 2060)
+++ trunk/src/python/osrf/system.py	2010-11-09 14:22:25 UTC (rev 2061)
@@ -101,11 +101,17 @@
     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)
 



More information about the opensrf-commits mailing list