Re: fixing debconf stdin bug
On Mon, Jan 12, 2004 at 05:08:25PM -0600, Steve Greenland wrote:
> On 12-Jan-04, 12:30 (CST), Matt Zimmerman <mdz@debian.org> wrote:
> > > Unfortunately, the only way AFAIK to do so is to do a { for all descriptors
> > > in (insert arbitrary range here, I use 255): close it ignoring errors }
> > > loop. Icky at best :(
> >
> > for(int i = 0; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
> > close(i);
>
> What makes you think sysconf(_SC_OPEN_MAX) is defined? It's allowed to
> be indeterminate, in which case sysconf() will return -1 and you won't
> close any of the descriptors. It'll work on Linux, but I'd guess not
> HURD.
>
> This is one of those cases where "icky" is actually the best solution,
> IMO. Even if sysconf() returns a value, suppose it's 32767? Do you
> really want to make that many syscalls every time it starts?
In practice, It Works. Using a sane default if sysconf returns -1 is of
course a good idea.
--
- mdz
Reply to: