emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113127: * process.c (create_process): Handle a coup


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113127: * process.c (create_process): Handle a couple more cases,
Date: Fri, 21 Jun 2013 22:16:40 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113127
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2013-06-21 15:16:37 -0700
message:
  * process.c (create_process): Handle a couple more cases,
  
  i.e., work even if new_argv and wait_child_setup[i] are cached.
  Use Fcall_process's style for volatile vars.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-06-21 21:27:17 +0000
+++ b/src/ChangeLog     2013-06-21 22:16:37 +0000
@@ -1,3 +1,9 @@
+2013-06-21  Paul Eggert  <address@hidden>
+
+       * process.c (create_process): Handle a couple more cases,
+       i.e., work even if new_argv and wait_child_setup[i] are cached.
+       Use Fcall_process's style for volatile vars.
+
 2013-06-21  Andreas Schwab  <address@hidden>
 
        * process.c (create_process): Mark PROCESS volatile.

=== modified file 'src/process.c'
--- a/src/process.c     2013-06-21 21:27:17 +0000
+++ b/src/process.c     2013-06-21 22:16:37 +0000
@@ -1582,8 +1582,7 @@
 
 
 static void
-create_process (volatile Lisp_Object process, char **new_argv,
-               Lisp_Object current_dir)
+create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
 {
   int inchannel, outchannel;
   pid_t pid;
@@ -1592,11 +1591,10 @@
   int wait_child_setup[2];
 #endif
   sigset_t blocked;
-  /* Use volatile to protect variables from being clobbered by vfork.  */
-  volatile int forkin, forkout;
-  volatile bool pty_flag = 0;
-  volatile Lisp_Object lisp_pty_name = Qnil;
-  volatile Lisp_Object encoded_current_dir;
+  int forkin, forkout;
+  bool pty_flag = 0;
+  Lisp_Object lisp_pty_name = Qnil;
+  Lisp_Object encoded_current_dir;
 
   inchannel = outchannel = -1;
 
@@ -1695,7 +1693,31 @@
   pthread_sigmask (SIG_BLOCK, &blocked, 0);
 
 #ifndef WINDOWSNT
-  pid = vfork ();
+  /* vfork, and prevent local vars from being clobbered by the vfork.  */
+  {
+    Lisp_Object volatile encoded_current_dir_volatile = encoded_current_dir;
+    Lisp_Object volatile lisp_pty_name_volatile = lisp_pty_name;
+    Lisp_Object volatile process_volatile = process;
+    bool volatile pty_flag_volatile = pty_flag;
+    char **volatile new_argv_volatile = new_argv;
+    int volatile forkin_volatile = forkin;
+    int volatile forkout_volatile = forkout;
+    int volatile wait_child_setup_0_volatile = wait_child_setup[0];
+    int volatile wait_child_setup_1_volatile = wait_child_setup[1];
+
+    pid = vfork ();
+
+    encoded_current_dir = encoded_current_dir_volatile;
+    lisp_pty_name = lisp_pty_name_volatile;
+    process = process_volatile;
+    pty_flag = pty_flag_volatile;
+    new_argv = new_argv_volatile;
+    forkin = forkin_volatile;
+    forkout = forkout_volatile;
+    wait_child_setup[0] = wait_child_setup_0_volatile;
+    wait_child_setup[1] = wait_child_setup_1_volatile;
+  }
+
   if (pid == 0)
 #endif /* not WINDOWSNT */
     {


reply via email to

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