mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
USE subprocess.Popen API correctly.
When collecting stdout/stderr *and* feeding data into a Popen instance, communicate() must be used to avoid a known deadlocking scenario when data sizes cross PIPE_BUF (which can be as small as 512, although should be much larger in practice on linux).
This commit is contained in:
parent
7ecb2b6728
commit
2174230315
1 changed files with 2 additions and 3 deletions
|
@ -935,10 +935,9 @@ class AnsibleModule(object):
|
|||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
if data:
|
||||
cmd.stdin.write(data)
|
||||
if not binary_data:
|
||||
cmd.stdin.write('\\n')
|
||||
out, err = cmd.communicate()
|
||||
data += '\\n'
|
||||
out, err = cmd.communicate(input=data)
|
||||
rc = cmd.returncode
|
||||
except (OSError, IOError), e:
|
||||
self.fail_json(rc=e.errno, msg=str(e), cmd=args)
|
||||
|
|
Loading…
Reference in a new issue