BBlack has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134651

Change subject: fix daemonization stdio stuff
......................................................................

fix daemonization stdio stuff

Change-Id: I2c608fc493f0bc5219700c0423e0d55940965823
---
M pybal/pybal.py
1 file changed, 8 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/51/134651/1

diff --git a/pybal/pybal.py b/pybal/pybal.py
index 0de71db..43ad576 100644
--- a/pybal/pybal.py
+++ b/pybal/pybal.py
@@ -616,24 +616,15 @@
     else:
         os._exit( 0 )         # Exit parent of the first child.
 
-    # Close all open files.  Try the system configuration variable, 
SC_OPEN_MAX,
-    # for the maximum number of open files to close.  If it doesn't exist, use
-    # the default value (configurable).
-    try:
-        maxfd = os.sysconf( "SC_OPEN_MAX" )
-    except ( AttributeError, ValueError ):
-        maxfd = 256       # default maximum
-
-    #for fd in range( 0, maxfd ):
-    #    try:
-    #        os.close( fd )
-    #    except OSError:   # ERROR (ignore)
-    #        pass
-
     # Redirect the standard file descriptors to /dev/null.
-    os.open( "/dev/null", os.O_RDONLY )    # standard input (0)
-    os.open( "/dev/null", os.O_RDWR )       # standard output (1)
-    os.open( "/dev/null", os.O_RDWR )       # standard error (2)
+    sys.stdin.flush()
+    sys.stdout.flush()
+    sys.stderr.flush()
+    null = os.open(os.devnull, os.O_RDWR)
+    os.dup2(null, sys.stdin.fileno())
+    os.dup2(null, sys.stdout.fileno())
+    os.dup2(null, sys.stderr.fileno())
+    os.close(null)
 
     return( 0 )
 

-- 
To view, visit https://gerrit.wikimedia.org/r/134651
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c608fc493f0bc5219700c0423e0d55940965823
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: BBlack <bbl...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to