Can subprocess point to file descriptor 5?

Diez B. Roggisch deets at nospam.web.de
Wed May 3 05:10:12 EDT 2006


Steve Quezadas wrote:

> Hello,
> 
> I tried posting this to the web forums without much luck.
> 
> I have some simple subprocess code here:
> output = subprocess.Popen([/usr/bin/program"],
> stdout=subprocess.PIPE).communicate()[0]
> 
> However, /usr/bin/prgram also outputs not only to stdout and stderr but
> to file descriptor [5]. Can I redirect this output to either a file or a
> variable?

I doubt it writes to fd 5 - instead, it will open a few files/sockets/pipes
and writes to them. One of them happens to get the 5 assigned as
filedescriptor. Figure out which one (I guess you used strace to get that
number the firest hand?), and if it's a file, just read the contents of it.
If its anything else, I'm pretty much out of ideas, but maybe others
aren't.

Diez



More information about the Python-list mailing list