summaryrefslogtreecommitdiff
path: root/src/callproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 1d3d8764ff8..946670320ca 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -193,7 +193,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
int count = SPECPDL_INDEX ();
volatile USE_SAFE_ALLOCA;
- const unsigned char **volatile new_argv_volatile;
register const unsigned char **new_argv;
/* File to use for stderr in the child.
t means use same as standard output. */
@@ -416,7 +415,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
SAFE_ALLOCA (new_argv, const unsigned char **,
(nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
- new_argv_volatile = new_argv;
if (nargs > 4)
{
register size_t i;
@@ -591,9 +589,20 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
BLOCK_INPUT;
- pid = vfork ();
+ /* vfork, and prevent local vars from being clobbered by the vfork. */
+ {
+ int volatile fd_error_volatile = fd_error;
+ int volatile fd_output_volatile = fd_output;
+ int volatile output_to_buffer_volatile = output_to_buffer;
+ unsigned char const **volatile new_argv_volatile = new_argv;
+
+ pid = vfork ();
- new_argv = new_argv_volatile;
+ fd_error = fd_error_volatile;
+ fd_output = fd_output_volatile;
+ output_to_buffer = output_to_buffer_volatile;
+ new_argv = new_argv_volatile;
+ }
if (pid == 0)
{