we cannot use process.communicate() to feed the Popen with input,
because, upon return of process.communicate() the stdout,stderr are
closed. see https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate .
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit
6df444cf33a251f5dcb536606b44af696cdb4ed5)
Conflicts:
src/ceph-volume/ceph_volume/process.py
"""
stop_on_error = kw.pop('stop_on_error', True)
command_msg = obfuscate(command, kw.pop('obfuscate', None))
- stdin = kw.pop('stdin', None)
fail_msg = kw.pop('fail_msg', None)
logger.info(command_msg)
terminal.write(command_msg)
process = subprocess.Popen(
command,
- stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True,
**kw
)
- if stdin:
- process.communicate(stdin)
while True:
reads, _, _ = select(
[process.stdout.fileno(), process.stderr.fileno()],