changeset 12738:d06973e701f8

(getloadavg): Set FD_CLOEXEC flag on /dev/kmem file descriptor.
author Roland McGrath <roland@gnu.org>
date Tue, 01 Aug 1995 18:29:36 +0000
parents 7b804de92243
children ae2e8daffa31
files src/getloadavg.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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.  */