From db6c0e74f1e0483060623ed68c49107685902e65 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 2 May 2011 23:26:40 -0700 Subject: * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering. --- src/callproc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/callproc.c') diff --git a/src/callproc.c b/src/callproc.c index 4a29e95b356..c2c301eb4a5 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -192,7 +192,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. */ @@ -415,7 +414,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; @@ -590,9 +588,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; - new_argv = new_argv_volatile; + pid = vfork (); + + 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) { -- cgit v1.2.3