Re: FD_CLFORK or equivalent?

James H. Cloos Jr. (cloos@jhcloos.com)
05 May 1999 15:10:22 -0500


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

- -JimC
- --
James H. Cloos, Jr. <http://www.jhcloos.com/cloos/public_key> 1024D/ED7DAEA6
<cloos@jhcloos.com> E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v0.9.5 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE3MKWumXqfF+19rqYRAvZbAJ9J7099fas8+3TpnQs/sPolhFtg+QCgmiYX
VaP/sndR0KOS6grv3eHB5dA=
=aCmo
-----END PGP SIGNATURE-----

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