[net.unix-wizards] re-using file descriptors

gjm (01/20/83)

I need a fix for the following bug/coding problem:

Suppose that a section of code uses section 3 functions like
popen(3) and pclose(3).  If the code is executed only a few times,
it works fine, but if executed many times, an error occurs reading
"cannot make pipe".

This leads me to believe that file descriptors are being consumed,
especially since the number of passes turn out about right.  Each
popen has its corresponding pclose, so it is simply a matter of the
internals not re-using the file descriptors.

The question is: what is the cleanest way to re-use file descriptors
(especially since section 3 functions use FILE streams while section
2 system calls use file descriptor indices).  I would like to keep
the code fairly intact with the simplicity of the popen's, but
larger changes are workable if necessary.

Please respond to me via mail.  I will summarize if people are interested.

Gary Murakami
Bell Labs - Indian Hill
ihnp4!gjm