diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-12-02 11:16:45 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-12-02 11:16:45 -0800 |
commit | 21e54a94d7527e07ddc37066c8cb488f478339c9 (patch) | |
tree | 714c6cb2b4170123769e70a62d295cc24ed998f3 /src/callproc.c | |
parent | 010db6da6527d16736fd3c2b607058dd35a70c9a (diff) | |
download | emacs-21e54a94d7527e07ddc37066c8cb488f478339c9.tar.gz emacs-21e54a94d7527e07ddc37066c8cb488f478339c9.tar.bz2 emacs-21e54a94d7527e07ddc37066c8cb488f478339c9.zip |
Use execve to avoid need to munge environ.
* callproc.c (Fcall_process):
* process.c (create_process):
Don't save and restore environ; no longer needed.
* callproc.c (child_setup):
Use execve, not execvp, to preserve environ.
Fixes: debbugs:13054
Diffstat (limited to 'src/callproc.c')
-rw-r--r-- | src/callproc.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/src/callproc.c b/src/callproc.c index 167663a45c6..0242755eb5f 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -488,9 +488,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) } { - /* child_setup must clobber environ in systems with true vfork. - Protect it from permanent change. */ - char **save_environ = environ; int fd_error = fd1; if (fd_output >= 0) @@ -594,7 +591,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) ptrdiff_t volatile count_volatile = count; ptrdiff_t volatile sa_count_volatile = sa_count; char **volatile new_argv_volatile = new_argv; - char **volatile new_save_environ = save_environ; pid = vfork (); @@ -612,7 +608,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) count = count_volatile; sa_count = sa_count_volatile; new_argv = new_argv_volatile; - save_environ = new_save_environ; } if (pid == 0) @@ -638,8 +633,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) emacs_close (fd_error); #endif /* not MSDOS */ - environ = save_environ; - /* Close most of our file descriptors, but not fd0 since we will use that to read input from. */ emacs_close (filefd); @@ -1092,10 +1085,6 @@ add_env (char **env, char **new_env, char *string) Initialize inferior's priority, pgrp, connected dir and environment. then exec another program based on new_argv. - This function may change environ for the superior process. - Therefore, the superior process must save and restore the value - of environ around the vfork and the call to this function. - If SET_PGRP, put the subprocess into a separate process group. CURRENT_DIR is an elisp string giving the path of the current @@ -1298,11 +1287,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, setpgid (0, 0); tcsetpgrp (0, pid); - /* execvp does not accept an environment arg so the only way - to pass this environment is to set environ. Our caller - is responsible for restoring the ambient value of environ. */ - environ = env; - execvp (new_argv[0], new_argv); + execve (new_argv[0], new_argv, env); emacs_write (1, "Can't exec program: ", 20); emacs_write (1, new_argv[0], strlen (new_argv[0])); |