diff options
author | Roland McGrath <roland@gnu.org> | 1995-08-01 18:29:36 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-08-01 18:29:36 +0000 |
commit | 00f7bd7264f701b65656043ffa064fcb46a175dd (patch) | |
tree | 21b25b4c935adc85c314e78ee366e732d879894a /src/getloadavg.c | |
parent | eec4c3ca05a1b713a116486e90143a8cf0ad7c78 (diff) | |
download | emacs-00f7bd7264f701b65656043ffa064fcb46a175dd.tar.gz |
(getloadavg): Set FD_CLOEXEC flag on /dev/kmem file descriptor.
Diffstat (limited to 'src/getloadavg.c')
-rw-r--r-- | src/getloadavg.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/getloadavg.c b/src/getloadavg.c index 8689a81eb50..5cf0b997bad 100644 --- a/src/getloadavg.c +++ b/src/getloadavg.c @@ -840,7 +840,17 @@ getloadavg (loadavg, nelem) #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. */ |