[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dh_installinit

On Mon, 2007-11-12 at 12:34 -0600, Steve Greenland wrote:
> On 11-Nov-07, 14:25 (CST), Arthur de Jong <adejong@debian.org> 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 - adejong@debian.org - http://people.debian.org/~adejong --

Attachment: signature.asc
Description: This is a digitally signed message part

Reply to: