emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/process.c,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/process.c,v
Date: Thu, 17 Jul 2008 23:19:01 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     08/07/17 23:18:59

Index: process.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/process.c,v
retrieving revision 1.550
retrieving revision 1.551
diff -u -b -r1.550 -r1.551
--- process.c   16 Jul 2008 08:06:17 -0000      1.550
+++ process.c   17 Jul 2008 23:18:55 -0000      1.551
@@ -1851,6 +1851,9 @@
   int inchannel, outchannel;
   pid_t pid;
   int sv[2];
+#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
+  int wait_child_setup[2];
+#endif
 #ifdef POSIX_SIGNALS
   sigset_t procmask;
   sigset_t blocked;
@@ -1924,6 +1927,25 @@
       forkin = sv[0];
     }
 
+#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
+    {
+      int tem;
+
+      tem = pipe (wait_child_setup);
+      if (tem < 0)
+       report_file_error ("Creating pipe", Qnil);
+      tem = fcntl (wait_child_setup[1], F_GETFD, 0);
+      if (tem >= 0)
+       tem = fcntl (wait_child_setup[1], F_SETFD, tem | FD_CLOEXEC);
+      if (tem < 0)
+       {
+         emacs_close (wait_child_setup[0]);
+         emacs_close (wait_child_setup[1]);
+         report_file_error ("Setting file descriptor flags", Qnil);
+       }
+    }
+#endif
+
 #if 0
   /* Replaced by close_process_descs */
   set_exclusive_use (inchannel);
@@ -2158,6 +2180,9 @@
        pid = child_setup (xforkin, xforkout, xforkout,
                           new_argv, 1, current_dir);
 #else  /* not WINDOWSNT */
+#ifdef FD_CLOEXEC
+       emacs_close (wait_child_setup[0]);
+#endif
        child_setup (xforkin, xforkout, xforkout,
                     new_argv, 1, current_dir);
 #endif /* not WINDOWSNT */
@@ -2211,6 +2236,20 @@
       else
 #endif
        XPROCESS (process)->tty_name = Qnil;
+
+#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
+      /* Wait for child_setup to complete in case that vfork is
+        actually defined as fork.  The descriptor wait_child_setup[1]
+        of a pipe is closed at the child side either by close-on-exec
+        on successful execvp or the _exit call in child_setup.  */
+      {
+       char dummy;
+
+       emacs_close (wait_child_setup[1]);
+       emacs_read (wait_child_setup[0], &dummy, 1);
+       emacs_close (wait_child_setup[0]);
+      }
+#endif
     }
 
   /* Restore the signal state whether vfork succeeded or not.
@@ -4666,15 +4705,6 @@
 #endif
 
          Atemp = input_wait_mask;
-#if 0
-          /* On Mac OS X 10.0, the SELECT system call always says input is
-             present (for reading) at stdin, even when none is.  This
-             causes the call to SELECT below to return 1 and
-             status_notify not to be called.  As a result output of
-             subprocesses are incorrectly discarded.
-         */
-          FD_CLR (0, &Atemp);
-#endif
          IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
 
          EMACS_SET_SECS_USECS (timeout, 0, 0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]