Re: FD_CLFORK or equivalent?

Richard B. Johnson (root@chaos.analogic.com)
Wed, 5 May 1999 16:45:47 -0400 (EDT)


On 5 May 1999, James H. Cloos Jr. wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> >>>>> "Richard" == Richard B Johnson <root@chaos.analogic.com> writes:
>
> Richard> But... The 'standard' way is:
>
> Richard> fd = open("/", O_RDONLY);
> Richard> while (fd >= 0) (void)close(fd--);
>
> Would this not be more accurate:
>
> struct rlimit *rlim;
> if (getrlimit(RLIMIT_NOFILE, rlim)) { /* error */ }
> fd = rlim->rlim_cur;
> while (fd >=0 ) (void)close(fd--);
>
> Hmmm. Should calling setrlimit(RLIMIT_NOFILE, (struct rlimit *)NULL)
> close all open files? It of course doesn't, but should it?
>

You bring up an interesting point for which I have no answer.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
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/