On Mon, 2007-11-12 at 12:34 -0600, Steve Greenland wrote: > On 11-Nov-07, 14:25 (CST), Arthur de Jong <[EMAIL PROTECTED]> wrote: > > This seems to be quite common code (from one of my packages (cvsd), > > don't know what the original source for this code was): > > > > m=sysconf(_SC_OPEN_MAX); > > for (i=0;i<m;i++) > > close(i); > > > > There are hurd packages for this package so that should also work. > > Wrong. That code is buggy. The limit of OPEN_MAX can be indeterminate, > and thus sysconf(_SC_OPEN_MAX) can return -1.
Thanks, fixed that in my code (if the call returns negative, we just close the first 32 file descriptors and hope that's enough). Anyone have a better way to detect the highest open file descriptor (preferably something that also works inside a chroot jail that does not have /proc mounted)? NetBSD seems to have fcntl(F_MAXFD) that should do the trick, but it's unavailable on Linux. -- -- arthur - [EMAIL PROTECTED] - http://people.debian.org/~adejong --
signature.asc
Description: This is a digitally signed message part