I have a small python script launching several sub processes in parallel. I redirect STDOUT to PIPE and STDERR to STDOUT.
The process is a C++ binary which writes to STDOUT and STDERR in case of error.
I wait for each process to terminate in a for loop than I use communicate to read the output.
Short pseudocode:
cmd = [...]
process = subprocess.Popen(cmd, cwd=..., stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
process.wait()
print process.communicate()[0]
In some runs, depending on the redirected data size I guess, my C++ application blocks in fwrite() by trying to write to STDERR and it stays blocked forever.
If I replace stderr=subprocess.STDOUT to stderr=None everything goes fine.
I tried to play with the bufSize parameter of the Popen but without any results.