From: Sam Lang Date: Thu, 2 May 2013 15:49:50 +0000 (-0500) Subject: task/daemon-helper: Add nostdin option X-Git-Tag: 1.1.0~2163 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c0f1ef73737dd68774e90f356532ead2b0487784;p=teuthology.git task/daemon-helper: Add nostdin option 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 --- diff --git a/teuthology/task/daemon-helper b/teuthology/task/daemon-helper index c289d44fc..51b990865 100755 --- a/teuthology/task/daemon-helper +++ b/teuthology/task/daemon-helper @@ -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)