]> git.eshelyaron.com Git - emacs.git/commitdiff
* callproc.c (child_setup, relocate_fd) [!DOS_NT]:
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Jul 2013 00:30:45 +0000 (17:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Jul 2013 00:30:45 +0000 (17:30 -0700)
* process.c (create_process) [!DOS_NT]:
Remove now-unnecessary calls to emacs_close.

src/ChangeLog
src/callproc.c
src/process.c

index 101672baa1eae84791fb755422465da41e38cfda..6ee0cacb5209941f2dd33aa97c39b7f39fa38f57 100644 (file)
@@ -1,3 +1,9 @@
+2013-07-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * 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  <eliz@gnu.org>
 
        * w32term.c (x_draw_hollow_cursor): Delete the brush object when
index 30f9dc58d46bfd50b27d697a0747a10a10ae4d52..cdf92422b4d7fb19e4fff6e782f0d03faf9b4f1e 100644 (file)
@@ -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;
     }
 }
index 4a38c47443af38cbd626a11d13e5e1615ffe5785..8589acaa8b516b0e530a98f38913487649835bbd 100644 (file)
@@ -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 */