# HG changeset patch # User Roland McGrath # Date 807301776 0 # Node ID d06973e701f8368942042e30586cf26a177ec6bb # Parent 7b804de922435abd1244b6d0fadb3312875c64d0 (getloadavg): Set FD_CLOEXEC flag on /dev/kmem file descriptor. diff -r 7b804de92243 -r d06973e701f8 src/getloadavg.c --- a/src/getloadavg.c Tue Aug 01 06:44:48 1995 +0000 +++ b/src/getloadavg.c Tue Aug 01 18:29:36 1995 +0000 @@ -840,7 +840,17 @@ #ifndef SUNOS_5 channel = open ("/dev/kmem", 0); if (channel >= 0) - getloadavg_initialized = 1; + { + /* Set the channel to close on exec, so it does not + litter any child's descriptor table. */ +#ifdef FD_SETFD +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif + (void) fcntl (channel, F_SETFD, FD_CLOEXEC); +#endif + getloadavg_initialized = 1; + } #else /* SUNOS_5 */ /* We pass 0 for the kernel, corefile, and swapfile names to use the currently running kernel. */