From 4700b5a52dd4dcb27c4beee2c3fda4bfd0ac0e74 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 13 Jul 2013 17:30:45 -0700 Subject: [PATCH] * callproc.c (child_setup, relocate_fd) [!DOS_NT]: * process.c (create_process) [!DOS_NT]: Remove now-unnecessary calls to emacs_close. --- src/ChangeLog | 6 ++++++ src/callproc.c | 19 +++++++------------ src/process.c | 1 - 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 101672baa1e..6ee0cacb520 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-07-14 Paul Eggert + + * callproc.c (child_setup, relocate_fd) [!DOS_NT]: + * process.c (create_process) [!DOS_NT]: + Remove now-unnecessary calls to emacs_close. + 2013-07-13 Eli Zaretskii * w32term.c (x_draw_hollow_cursor): Delete the brush object when diff --git a/src/callproc.c b/src/callproc.c index 30f9dc58d46..cdf92422b4d 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1346,21 +1346,13 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, } #ifndef MSDOS - emacs_close (0); - emacs_close (1); - emacs_close (2); - - /* Redirect file descriptors and clear FD_CLOEXEC on the redirected ones. */ + /* Redirect file descriptors and clear the close-on-exec flag on the + redirected ones. IN, OUT, and ERR are close-on-exec so they + need not be closed explicitly. */ dup2 (in, 0); dup2 (out, 1); dup2 (err, 2); - emacs_close (in); - if (out != in) - emacs_close (out); - if (err != in && err != out) - emacs_close (err); - setpgid (0, 0); tcsetpgrp (0, pid); @@ -1386,7 +1378,8 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, #ifndef WINDOWSNT /* Move the file descriptor FD so that its number is not less than MINFD. - If the file descriptor is moved at all, the original is freed. */ + If the file descriptor is moved at all, the original is closed on MSDOS, + but not elsewhere as the caller will close it anyway. */ static int relocate_fd (int fd, int minfd) { @@ -1400,7 +1393,9 @@ relocate_fd (int fd, int minfd) emacs_perror ("while setting up child"); _exit (EXIT_CANCELED); } +#ifdef MSDOS emacs_close (fd); +#endif return new; } } diff --git a/src/process.c b/src/process.c index 4a38c47443a..8589acaa8b5 100644 --- a/src/process.c +++ b/src/process.c @@ -1831,7 +1831,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) pid = child_setup (xforkin, xforkout, xforkout, new_argv, 1, encoded_current_dir); #else /* not WINDOWSNT */ - emacs_close (wait_child_setup[0]); child_setup (xforkin, xforkout, xforkout, new_argv, 1, encoded_current_dir); #endif /* not WINDOWSNT */ -- 2.39.2