In 2018, we can assume everyone has implemented FD_CLOEXEC.

Back in 1970, 20 file descriptors was enough for any program, but
today they're effectively unlimited, so futilely closing _SC_OPEN_MAX
descriptors has become unreasonable (as you say).  OTOH, there is
still no standard way of ensuring all our file descriptors are closed.
Do we need the fallback on your beloved HP-UX?  Should we simply close
the first 64k file descriptors and pray, as is traditional?

freebsd offers closefrom(2)
https://www.freebsd.org/cgi/man.cgi?query=closefrom&sektion=2&manpath=freebsd-release-ports
and today we can autoconfiscate the existence of closefrom and use
that where available (BSD and Solaris?)

closeDescriptors needs a better name now - maybe ensureDescriptorsAreClosed ?

I'd give this function a javadoc style docstring.

(Finding the FD_DIR directory has become rather ugly, especially the
AIX-specific code)

Reply via email to