Excellent suggestion. Moreover, we now no longer a new system call.
In pseudo C mixed with pseudo Perl
DIR *dir = opendir("/proc/$$/fd");
while (d = readdir(dir)) {
close(atoi(d->d_name)); /* and handle error */
}
Hurray, no new sys call needed. It scales nicely and may even be
faster on systems with only 256 descriptors since it replaces 253
close() syscalls with 1 open plus 1 getdents + n(open_files) closes.
One of the original messages said perl did the "lots of closes" thing
but it doesn't. It just sets close-on-exec on all descriptors above
the last "system" descriptor, changeable by the special $^F variable
or $SYSTEM_FD_MAX is you're "use English"-inclined. It's mainly things
like login, daemons and security-related code which close everything.
Getting them all to change, assuming I haven't missed anything and
assuming that the benefit outweighs the loss of portability (which it
might not), is going to be non-trivial though. But this is all now
off-topic for linux-kernel so I'll stop there.
--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/