]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
task/daemon-helper: Add nostdin option
authorSam Lang <sam.lang@inktank.com>
Thu, 2 May 2013 15:49:50 +0000 (10:49 -0500)
committerSage Weil <sage@inktank.com>
Tue, 7 May 2013 00:37:25 +0000 (17:37 -0700)
Some daemons (smbd) will try to read from stdin and check if its a
socket, using that for sending/receiving messages.  If /dev/null is
used for stdin, the daemon aborts.  This patch adds a 'nostdin' option
to the daemon-helper so that the daemon can be started without /dev/null
as stdin.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
teuthology/task/daemon-helper

index c289d44fc00db1c495238beca68674f672447c66..51b990865af198c37fba32ed88688871f8761db7 100755 (executable)
@@ -25,11 +25,24 @@ end_signal = signal.SIGKILL
 if sys.argv[1] == "term":
     end_signal = signal.SIGTERM
 
-with file('/dev/null', 'rb') as devnull:
+cmd_start = 2
+
+nostdin = False
+if sys.argv[cmd_start] == "nostdin":
+    nostdin = True
+    cmd_start += 1
+
+proc = None
+if nostdin:
     proc = subprocess.Popen(
-        args=sys.argv[2:],
-        stdin=devnull,
+        args=sys.argv[cmd_start:],
         )
+else:
+    with file('/dev/null', 'rb') as devnull:
+        proc = subprocess.Popen(
+            args=sys.argv[cmd_start:],
+            stdin=devnull,
+            )
 
 flags = fcntl.fcntl(0, fcntl.F_GETFL)
 fcntl.fcntl(0, fcntl.F_SETFL, flags | os.O_NDELAY)