summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-08-01 18:38:49 +0000
committerRoland McGrath <roland@redhat.com>1995-08-01 18:38:49 +0000
commitd02b26a4b8373db81598db9ebe6c2e82cbd6e1ba (patch)
tree0334de349a6f89bea0a87a1332030fc22b782f7c /job.c
parent8b3f13f6ec84bf24954cae07576ae70086547e1c (diff)
downloadgunmake-d02b26a4b8373db81598db9ebe6c2e82cbd6e1ba.tar.gz
(start_job_command): Set FD_CLOEXEC flag on BAD_STDIN descriptor.
Diffstat (limited to 'job.c')
-rw-r--r--job.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/job.c b/job.c
index 77bbbae..b62c2f5 100644
--- a/job.c
+++ b/job.c
@@ -35,6 +35,12 @@ static char *dos_bename;
static int dos_batch_file;
#endif /* MSDOS. */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#else
+#include <sys/file.h>
+#endif
+
/* If NGROUPS_MAX == 0 then try other methods for finding a real value. */
#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
@@ -641,6 +647,16 @@ start_job_command (child)
(void) close (pd[1]);
/* Save the read side. */
bad_stdin = pd[0];
+
+ /* Set the descriptor to close on exec, so it does not litter any
+ child's descriptor table. When it is dup2'd onto descriptor 0,
+ that descriptor will not close on exec. */
+#ifdef FD_SETFD
+#ifndef FD_CLOEXEC
+#define FD_CLOEXEC 1
+#endif
+ (void) fcntl (bad_stdin, F_SETFD, FD_CLOEXEC);
+#endif
}
}