popen question

Hrvoje Niksic hniksic at xemacs.org
Tue Jan 8 06:52:46 EST 2008


Robert Latest <boblatest at yahoo.com> writes:

>> If you see lines one by one, you are in luck, and you can fix things
>> on the Python level simply by avoiding buffering in popen.  If not,
>> you will need to resort to more advanced hackery (e.g. fixing stdio
>> using LD_PRELOAD).
>
> Do I really? After all, the shell itself doesn't hack stdio, does
> it?

Have you tried the "./slow | cat" test?  It's not about the shell
doing anything special, it's about slow's stdio choosing buffering
"appropriate" for the output device.  The hackery I referred to would
be necessary to force slow's stdio to use line buffering over
file/pipe output simply because there is no documented way to do that
(that I know of).

> Anyway, I'm taking this over to comp.unix.programmer since it really
> isn't a python problem.

It's still an often-encountered problem, so I believe a summary of the
solution(s) would be appreciated.



More information about the Python-list mailing list