Messages in this thread | | | Date | Fri, 26 Mar 1999 07:43:11 +1100 | From | Richard Gooch <> | Subject | Re: modutils (Re: cipe 1.2.0 & kernel 2.2.x) |
| |
Malcolm Beattie writes: > Olaf Titz writes: > > I assume this is just this code in ciped: > > for (i=getdtablesize()-1; i>2; --i) > > (void) close(i); > > which makes sure all fds are closed (and deliberately ignores the > > errors). Are your 1000 really 253 or do you use an -ac kernel with > > higher fd limit? :-) > > > > This "close everything but standard fds" is employed by a number of > > programs, among them shells and perl, to avoid fd leakage. It is > > harmless. > > 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.
If you really want to do this, use a poll(2)-like interface instead. poll(2) is more scalable than select(2) and a structure like struct follfd could return status information about each FD.
Regards,
Richard....
- 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/
| |