From: Paul Eggert Date: Fri, 21 Jun 2013 22:16:37 +0000 (-0700) Subject: * process.c (create_process): Handle a couple more cases, X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2012 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cbd6509c2955134034f776bed5cfaf1754770aee;p=emacs.git * 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 0061b7ff9db..bdb8baf65d8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-06-21 Paul Eggert + + * 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 * process.c (create_process): Mark PROCESS volatile. diff --git a/src/process.c b/src/process.c index e74d58dcc33..c61a22c4beb 100644 --- a/src/process.c +++ b/src/process.c @@ -1582,8 +1582,7 @@ create_process_1 (struct atimer *timer) 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 @@ create_process (volatile Lisp_Object process, char **new_argv, 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 @@ create_process (volatile Lisp_Object process, char **new_argv, 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 */ {