summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-08-01 18:46:37 +0000
committerRoland McGrath <roland@redhat.com>1995-08-01 18:46:37 +0000
commit2c27d8dbdc8652bcbef4850460b480f04e76e0d8 (patch)
tree3ea5e034309ccbe1311933fe81c649ab11076d41 /job.c
parentd02b26a4b8373db81598db9ebe6c2e82cbd6e1ba (diff)
downloadgunmake-2c27d8dbdc8652bcbef4850460b480f04e76e0d8.tar.gz
(child_execute_job): Close STDIN_FD and STDOUT_FD after dup'ing from them.
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.
Diffstat (limited to 'job.c')
-rw-r--r--job.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/job.c b/job.c
index b62c2f5..7bb336c 100644
--- 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);