Trouble with popen2

Albert Hofkamp hat at se-126.se.wtb.tue.nl
Tue Sep 28 06:33:31 EDT 2004


On Mon, 27 Sep 2004 15:27:56 -0400, Rembrandt Q Einstein <hercules.rockefeller at springfield.??.us> wrote:
>> The challenge is to write a program that will run this one in a 
>> subprocess and read all of both stderr and stdout.
> 
> Ah--despite my new nick, I am an idiot.  I should just use select() on 
> fromchild and childerr.  Something like this:
> 
> while f.poll() == -1:
>    select([], [f.fromchild, f.childerr],[], 0)
>      blah
> 
> However, I think I might still miss some data this way.

Nope, this should work, assuming that you catch the output of select,
and act accordingly.
(at least, that is my experience)

Not sure why you need the f.poll() though, I think you can do without.



Maybe an extension to the documentation of popen would be in order, this
post pops up quite often here.

-- 
Albert
-- 
Unlike popular belief, the .doc format is not an open publically available format.



More information about the Python-list mailing list