Synchronous capture of stdout and stderr

Konrad Wojas usenet at
Sat Aug 31 18:37:24 CEST 2002

Neil Hodgson wrote:

> Konrad Wojas wrote:
>> I'm working on a build tool that captures the stdout and stderr of an
>> application and mails the output if a compile fails. I'm now using
>> popen2.popen3 and the select module, but I don't receive the two streams
>> in the same order as the application sends them.
>     A common problem here is that the application buffers the streams
> when writing to a pipe but not when writing to a terminal. Using a pty
> instead may convince the child application to run unbuffered. Is there a
> flag (like Python's -u) to run the application in unbuffered mode?

No, the applications are make and gcc :)

I guess I'll have to use popen4 and don't distinguish between stdout and 
stderr. Maybe I could try writing a LD_PRELOAD wrapper some time.


Konrad Wojas

More information about the Python-list mailing list