My python code spawns the child process, and it prints out messages both stdout and stderr. I need to print them differently.
I have the following code to spawn child process and get the stdout result from it.
cmd = ["vsmake.exe", "-f"]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
for line in iter(p.stdout.readline, ''):
print line,
sys.stdout.flush()
pass
p.wait()
How can I modify the code to check if the child process prints out message through stderr also?
ADDED
I need to print out the stderr and stdout as soon as the child process prints out something. And it is cross platform implementation, so it should run on Mac/Linux/PC.
select()
nor non-blocking I/O). – Abiotic