Auteur: Richard.Hall Date: À: exim-dev Sujet: Re: [exim-dev] [patch] please consider closing all fds on daemon
startup (was: Changes in the daemon startup code,
fd's not properly closed?)
Philip et al,
On Wed, 2 Mar 2005, Philip Hazel wrote:
[...] > Early releases of Exim had this line in the daemon code:
>
> for (fd = mac_maxfd; fd >= 0; fd--) close(fd); [...] > 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.
I have no opinion on the rights and/or wrongs of it. But just FYI, Solaris
(9 or above, I believe) and at least one variant of BSD have a closefrom()
function which is rumoured to reduce the cost of this significantly.