From: utzoo!decvax!duke!harpo!eagle!wb2!houxz!ihnp4!gjm
Newsgroups: net.unix-wizards
Title: re-using file descriptors
Article-I.D.: ihnp4.181
Posted: Thu Jan 20 03:20:14 1983
Received: Fri Jan 21 08:00:39 1983
Reply-To: gjm@ihnp4.UUCP (G. J. Murakami)


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