aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2009-04-29 19:55:49 +0000
committerAndreas Schwab2009-04-29 19:55:49 +0000
commitad3aaf330a79d6a4d42306809abff941b639950f (patch)
treee7558ac4e6ff882fb5d4f8d359b5f8baffdf0cc2 /src
parent9c358bdab1583b391335a75777d299f0d38f26b9 (diff)
downloademacs-ad3aaf330a79d6a4d42306809abff941b639950f.tar.gz
emacs-ad3aaf330a79d6a4d42306809abff941b639950f.zip
(Fcall_process): Fix GC protection. Make sure
current buffer is always restored.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/callproc.c36
2 files changed, 27 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 654f8756d30..ab9af25330c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12009-04-29 Andreas Schwab <schwab@linux-m68k.org>
2
3 * callproc.c (Fcall_process): Fix GC protection. Make sure
4 current buffer is always restored.
5
12009-04-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 62009-04-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 7
3 * atimer.c (init_atimer): Also clear stopped_atimers. 8 * atimer.c (init_atimer): Also clear stopped_atimers.
diff --git a/src/callproc.c b/src/callproc.c
index d55fe695e76..cab30475d63 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -153,18 +153,26 @@ call_process_kill (fdpid)
153} 153}
154 154
155Lisp_Object 155Lisp_Object
156call_process_cleanup (fdpid) 156call_process_cleanup (arg)
157 Lisp_Object fdpid; 157 Lisp_Object arg;
158{ 158{
159 Lisp_Object fdpid = Fcdr (arg);
160#if defined (MSDOS)
161 Lisp_Object file;
162#else
163 int pid;
164#endif
165
166 Fset_buffer (Fcar (arg));
167
159#if defined (MSDOS) 168#if defined (MSDOS)
160 /* for MSDOS fdpid is really (fd . tempfile) */ 169 /* for MSDOS fdpid is really (fd . tempfile) */
161 register Lisp_Object file;
162 file = Fcdr (fdpid); 170 file = Fcdr (fdpid);
163 emacs_close (XFASTINT (Fcar (fdpid))); 171 emacs_close (XFASTINT (Fcar (fdpid)));
164 if (strcmp (SDATA (file), NULL_DEVICE) != 0) 172 if (strcmp (SDATA (file), NULL_DEVICE) != 0)
165 unlink (SDATA (file)); 173 unlink (SDATA (file));
166#else /* not MSDOS */ 174#else /* not MSDOS */
167 register int pid = XFASTINT (Fcdr (fdpid)); 175 pid = XFASTINT (Fcdr (fdpid));
168 176
169 if (call_process_exited) 177 if (call_process_exited)
170 { 178 {
@@ -231,7 +239,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
231 int count = SPECPDL_INDEX (); 239 int count = SPECPDL_INDEX ();
232 240
233 register const unsigned char **new_argv; 241 register const unsigned char **new_argv;
234 struct buffer *old = current_buffer;
235 /* File to use for stderr in the child. 242 /* File to use for stderr in the child.
236 t means use same as standard output. */ 243 t means use same as standard output. */
237 Lisp_Object error_file; 244 Lisp_Object error_file;
@@ -399,9 +406,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
399 } 406 }
400 /* Search for program; barf if not found. */ 407 /* Search for program; barf if not found. */
401 { 408 {
402 struct gcpro gcpro1; 409 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
403 410
404 GCPRO1 (current_dir); 411 GCPRO4 (infile, buffer, current_dir, error_file);
405 openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK)); 412 openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK));
406 UNGCPRO; 413 UNGCPRO;
407 } 414 }
@@ -422,9 +429,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
422 if (nargs > 4) 429 if (nargs > 4)
423 { 430 {
424 register int i; 431 register int i;
425 struct gcpro gcpro1, gcpro2, gcpro3; 432 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
426 433
427 GCPRO3 (infile, buffer, current_dir); 434 GCPRO5 (infile, buffer, current_dir, path, error_file);
428 argument_coding.dst_multibyte = 0; 435 argument_coding.dst_multibyte = 0;
429 for (i = 4; i < nargs; i++) 436 for (i = 4; i < nargs; i++)
430 { 437 {
@@ -630,10 +637,13 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
630#if defined(MSDOS) 637#if defined(MSDOS)
631 /* MSDOS needs different cleanup information. */ 638 /* MSDOS needs different cleanup information. */
632 record_unwind_protect (call_process_cleanup, 639 record_unwind_protect (call_process_cleanup,
633 Fcons (make_number (fd[0]), build_string (tempfile))); 640 Fcons (Fcurrent_buffer (),
641 Fcons (make_number (fd[0]),
642 build_string (tempfile))));
634#else 643#else
635 record_unwind_protect (call_process_cleanup, 644 record_unwind_protect (call_process_cleanup,
636 Fcons (make_number (fd[0]), make_number (pid))); 645 Fcons (Fcurrent_buffer (),
646 Fcons (make_number (fd[0]), make_number (pid))));
637#endif /* not MSDOS */ 647#endif /* not MSDOS */
638 648
639 649
@@ -812,7 +822,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
812 coding-system used to decode the process output. */ 822 coding-system used to decode the process output. */
813 if (inherit_process_coding_system) 823 if (inherit_process_coding_system)
814 call1 (intern ("after-insert-file-set-buffer-file-coding-system"), 824 call1 (intern ("after-insert-file-set-buffer-file-coding-system"),
815 make_number (total_read)); 825 make_number (total_read));
816 } 826 }
817 827
818 /* Wait for it to terminate, unless it already has. */ 828 /* Wait for it to terminate, unless it already has. */
@@ -820,8 +830,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
820 830
821 immediate_quit = 0; 831 immediate_quit = 0;
822 832
823 set_buffer_internal (old);
824
825 /* Don't kill any children that the subprocess may have left behind 833 /* Don't kill any children that the subprocess may have left behind
826 when exiting. */ 834 when exiting. */
827 call_process_exited = 1; 835 call_process_exited = 1;