From c0f1ef73737dd68774e90f356532ead2b0487784 Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Thu, 2 May 2013 10:49:50 -0500 Subject: [PATCH] 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 --- teuthology/task/daemon-helper | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/teuthology/task/daemon-helper b/teuthology/task/daemon-helper index c289d44fc00db..51b990865af19 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) -- 2.39.5