mirror of
https://github.com/mirror/make.git
synced 2025-03-13 19:30:41 +08:00
(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.
This commit is contained in:
parent
d02b26a4b8
commit
2c27d8dbdc
12
job.c
12
job.c
@ -1068,14 +1068,10 @@ child_execute_job (stdin_fd, stdout_fd, argv, envp)
|
|||||||
(void) dup2 (stdin_fd, 0);
|
(void) dup2 (stdin_fd, 0);
|
||||||
if (stdout_fd != 1)
|
if (stdout_fd != 1)
|
||||||
(void) dup2 (stdout_fd, 1);
|
(void) dup2 (stdout_fd, 1);
|
||||||
|
if (stdin_fd != 0)
|
||||||
/* Free up file descriptors. */
|
(void) close (stdin_fd);
|
||||||
{
|
if (stdout_fd != 1)
|
||||||
register int d;
|
(void) close (stdout_fd);
|
||||||
int max = getdtablesize ();
|
|
||||||
for (d = 3; d < max; ++d)
|
|
||||||
(void) close (d);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run the command. */
|
/* Run the command. */
|
||||||
exec_command (argv, envp);
|
exec_command (argv, envp);
|
||||||
|
Loading…
Reference in New Issue
Block a user