On our heavily loaded Digital UNIX Alphaserver (which defaults to 4096
file descriptors per process), each "close everything but standard fds"
hits the system with another 4093 syscalls. When that's done frequently
(up to a few logins per second) it becomes a significant fraction of
the syscalls/sec which seems to correlate fairly well with the whole
system's performance.
Since Linux is now entering the realms of plenty of file descriptors,
I wonder if it's worth having a closefdset() syscall used as follows:
fd_set most;
FD_ZERO(&most);
for (i=getdtablesize()-1; i>2; --i)
FD_SET(i, &most);
closefdset(&most);
On the positive side, it reduces all those extra syscalls at a stroke
and it's simple to write. On the negative side, it's a non-standard
interface and could easily be considered a unnecessary wart. It also
can't return any errors beyond "at least one close failed" but that
doesn't matter for the purposes it would be used for.
--Malcolm
-- Malcolm Beattie <mbeattie@sable.ox.ac.uk> Unix Systems Programmer Oxford University Computing Services- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/