summaryrefslogtreecommitdiff
path: root/getloadavg.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-08-01 18:29:36 +0000
committerRoland McGrath <roland@redhat.com>1995-08-01 18:29:36 +0000
commit8b3f13f6ec84bf24954cae07576ae70086547e1c (patch)
tree90f3725278c0141cc436af01ed117b1ee552baad /getloadavg.c
parente74b6ae5c217dbab29c5e80c939f743c577ba42c (diff)
downloadgunmake-8b3f13f6ec84bf24954cae07576ae70086547e1c.tar.gz
(getloadavg): Set FD_CLOEXEC flag on /dev/kmem file descriptor.
Diffstat (limited to 'getloadavg.c')
-rw-r--r--getloadavg.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/getloadavg.c b/getloadavg.c
index 8689a81..5cf0b99 100644
--- a/getloadavg.c
+++ b/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. */