On Wed, 2 Mar 2005, Marc Haber wrote:
> I would like to suggest applying the attached patch to the exim sources.
Early releases of Exim had this line in the daemon code:
for (fd = mac_maxfd; fd >= 0; fd--) close(fd);
where mac_maxfd was defined thus:
/* The way of finding out the maximum file descriptor various between OS.
Most have sysconf(), but a few don't. */
#ifdef _SC_OPEN_MAX
#define mac_maxfd (sysconf(_SC_OPEN_MAX) - 1)
#elif defined OPEN_MAX
#define mac_maxfd (OPEN_MAX - 1)
#elif defined NOFILE
#define mac_maxfd (NOFILE - 1)
#else
#define mac_maxfd 255; /* just in case */
#endif
(I took that from the 1.62 source.) The problem with this was that
eventually somebody ran it on an operating system where the maximum
number of file descriptors was 32767 or whatever, and it took a
loooonnnggg time... So I changed to just dealing with
stdin/stdout/stderr.
The question therefore is: is it worth just closing 1-255? Will that
take significant time? Why not 1-127 or 1-63 or 1-511? Maybe this should
be configurable at build time?
Opinions, please.
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book: http://www.uit.co.uk/exim-book