From 6a18075640cd97174e561e446e7aedac2228c1e8 Mon Sep 17 00:00:00 2001 From: Dietmar Schinnerl Date: Sat, 11 Aug 2012 15:13:07 +0200 Subject: [PATCH] Issue #848: Closing stdin after we read from stdout --- lib/ansible/runner/connection/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection/ssh.py b/lib/ansible/runner/connection/ssh.py index 8c84246e4e..aaf429c54f 100644 --- a/lib/ansible/runner/connection/ssh.py +++ b/lib/ansible/runner/connection/ssh.py @@ -98,12 +98,12 @@ class SSHConnection(object): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # We can't use p.communicate here because the ControlMaster may have stdout open as well - p.stdin.close() stdout = '' while p.poll() is None: rfd, wfd, efd = select.select([p.stdout], [], [p.stdout], 1) if p.stdout in rfd: stdout += os.read(p.stdout.fileno(), 1024) + p.stdin.close() # close stdin after we read from stdout (see also issue #848) # older versions of ssh generate this error which we ignore stdout=stdout.replace("tcgetattr: Invalid argument\n", "") # suppress Ubuntu 10.04/12.04 error on -tt option