]> git.ipfire.org Git - thirdparty/make.git/commitdiff
(child_execute_job): Close STDIN_FD and STDOUT_FD after dup'ing from them.
authorRoland McGrath <roland@redhat.com>
Tue, 1 Aug 1995 18:46:37 +0000 (18:46 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 1 Aug 1995 18:46:37 +0000 (18:46 +0000)
Don't try to close all excess descriptors; getdtablesize might return
a huge value.  Any open descriptors in the parent should have FD_CLOEXEC
set.

job.c

diff --git a/job.c b/job.c
index b62c2f55c0c04a470802b94b4fbfb1447610cd42..7bb336c737938ade8a92299b4fc07005d2ab0967 100644 (file)
--- a/job.c
+++ b/job.c
@@ -1068,14 +1068,10 @@ child_execute_job (stdin_fd, stdout_fd, argv, envp)
     (void) dup2 (stdin_fd, 0);
   if (stdout_fd != 1)
     (void) dup2 (stdout_fd, 1);
-
-  /* Free up file descriptors.  */
-  {
-    register int d;
-    int max = getdtablesize ();
-    for (d = 3; d < max; ++d)
-      (void) close (d);
-  }
+  if (stdin_fd != 0)
+    (void) close (stdin_fd);
+  if (stdout_fd != 1)
+    (void) close (stdout_fd);
 
   /* Run the command.  */
   exec_command (argv, envp);