adfca8
Upstream report: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13054
adfca8
Upstream commit: 21e54a94d7527e07ddc37066c8cb488f478339c9
adfca8
Resolves: #1308518
adfca8
adfca8
--- emacs-24.3/src/callproc.c	2013-02-02 04:20:04.000000000 +0100
adfca8
+++ emacs-24.3-new/src/callproc.c	2016-02-29 08:24:53.628487375 +0100
adfca8
@@ -491,9 +491,6 @@ usage: (call-process PROGRAM &optional I
adfca8
     }
adfca8
 
adfca8
   {
adfca8
-    /* child_setup must clobber environ in systems with true vfork.
adfca8
-       Protect it from permanent change.  */
adfca8
-    register char **save_environ = environ;
adfca8
     register int fd1 = fd[1];
adfca8
     int fd_error = fd1;
adfca8
 
adfca8
@@ -640,8 +637,6 @@ usage: (call-process PROGRAM &optional I
adfca8
       emacs_close (fd_error);
adfca8
 #endif /* not MSDOS */
adfca8
 
adfca8
-    environ = save_environ;
adfca8
-
adfca8
     /* Close most of our fd's, but not fd[0]
adfca8
        since we will use that to read input from.  */
adfca8
     emacs_close (filefd);
adfca8
@@ -1098,10 +1093,6 @@ add_env (char **env, char **new_env, cha
adfca8
    Initialize inferior's priority, pgrp, connected dir and environment.
adfca8
    then exec another program based on new_argv.
adfca8
 
adfca8
-   This function may change environ for the superior process.
adfca8
-   Therefore, the superior process must save and restore the value
adfca8
-   of environ around the vfork and the call to this function.
adfca8
-
adfca8
    If SET_PGRP, put the subprocess into a separate process group.
adfca8
 
adfca8
    CURRENT_DIR is an elisp string giving the path of the current
adfca8
@@ -1308,11 +1299,7 @@ child_setup (int in, int out, int err, c
adfca8
   /* setpgrp_of_tty is incorrect here; it uses input_fd.  */
adfca8
   tcsetpgrp (0, pid);
adfca8
 
adfca8
-  /* execvp does not accept an environment arg so the only way
adfca8
-     to pass this environment is to set environ.  Our caller
adfca8
-     is responsible for restoring the ambient value of environ.  */
adfca8
-  environ = env;
adfca8
-  execvp (new_argv[0], new_argv);
adfca8
+  execve (new_argv[0], new_argv, env);
adfca8
 
adfca8
   emacs_write (1, "Can't exec program: ", 20);
adfca8
   emacs_write (1, new_argv[0], strlen (new_argv[0]));
adfca8
--- emacs-24.3/src/process.c	2013-01-01 21:37:17.000000000 +0100
adfca8
+++ emacs-24.3-new/src/process.c	2016-02-29 08:23:23.218671832 +0100
adfca8
@@ -1606,9 +1606,6 @@ create_process (Lisp_Object process, cha
adfca8
   volatile int pty_flag = 0;
adfca8
   volatile Lisp_Object lisp_pty_name = Qnil;
adfca8
   volatile Lisp_Object encoded_current_dir;
adfca8
-#if HAVE_WORKING_VFORK
adfca8
-  char **volatile save_environ;
adfca8
-#endif
adfca8
 
adfca8
   inchannel = outchannel = -1;
adfca8
 
adfca8
@@ -1728,12 +1725,6 @@ create_process (Lisp_Object process, cha
adfca8
   pthread_sigmask (SIG_BLOCK, &blocked, 0);
adfca8
 #endif
adfca8
 
adfca8
-#if HAVE_WORKING_VFORK
adfca8
-  /* child_setup must clobber environ on systems with true vfork.
adfca8
-     Protect it from permanent change.  */
adfca8
-  save_environ = environ;
adfca8
-#endif
adfca8
-
adfca8
 #ifndef WINDOWSNT
adfca8
   pid = vfork ();
adfca8
   if (pid == 0)
adfca8
@@ -1875,10 +1866,6 @@ create_process (Lisp_Object process, cha
adfca8
 
adfca8
   /* Back in the parent process.  */
adfca8
 
adfca8
-#if HAVE_WORKING_VFORK
adfca8
-  environ = save_environ;
adfca8
-#endif
adfca8
-
adfca8
   XPROCESS (process)->pid = pid;
adfca8
 
adfca8
   /* Stop blocking signals in the parent.  */
adfca8
@@ -1928,7 +1915,7 @@ create_process (Lisp_Object process, cha
adfca8
       /* Wait for child_setup to complete in case that vfork is
adfca8
 	 actually defined as fork.  The descriptor wait_child_setup[1]
adfca8
 	 of a pipe is closed at the child side either by close-on-exec
adfca8
-	 on successful execvp or the _exit call in child_setup.  */
adfca8
+	 on successful execve or the _exit call in child_setup.  */
adfca8
       {
adfca8
 	char dummy;
adfca8