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

Re: fixing debconf stdin bug



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?

Steve
-- 
Steve Greenland
    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world.       -- seen on the net



Reply to: