A subprocess whose std{out,err} is subprocess.PIPE may block writing its output, so .wait() should not be called on it until the pipes are read completely on the caller's side.
Subprocess.communicate takes care of this. Signed-off-by: Roman Kagan <rka...@virtuozzo.com> --- tests/qemu-iotests/iotests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b25d48a91b..e2abf0cb53 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -104,20 +104,20 @@ def qemu_img_pipe(*args): subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - exitcode = subp.wait() - if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) - return subp.communicate()[0] + output = subp.communicate()[0] + if subp.returncode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-subp.returncode, ' '.join(qemu_img_args + list(args)))) + return output def qemu_io(*args): '''Run qemu-io and return the stdout data''' args = qemu_io_args + list(args) subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - exitcode = subp.wait() - if exitcode < 0: - sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) - return subp.communicate()[0] + output = subp.communicate()[0] + if subp.returncode < 0: + sys.stderr.write('qemu-io received signal %i: %s\n' % (-subp.returncode, ' '.join(args))) + return output class QemuIoInteractive: -- 2.14.3