I'd set up the set(s) once and copy them from then on, possibly adding
or deleting bits as FDs are created/closed. Last time I checked, memcpy
was reasonably fast ...
Rogier Wolff wrote:
> If you want to be "portable" across different limits, use
> fd = fopen ("/proc/kernel/file-max","r");
Very nice. So you get one extra #ifdef linux or such, plus something
like file-max bits that will always be zero but you're scanning them
anyway (assuming fds_in_use << file-max). I'd calculate the maximum FD
number and use that (plus a bit more if allocating dynamic memory, so
that I don't have to realloc for each new FD). Redo the operation after
closing a lot of FDs.
- Werner
-- _________________________________________________________________________ / Werner Almesberger, DI-LRC,EPFL,CH werner.almesberger@lrc.di.epfl.ch / /_IN_R_133__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/