aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/callproc.c b/src/callproc.c
index ad3eddbdd39..b5b8cadeb68 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1,5 +1,5 @@
1/* Synchronous subprocess invocation for GNU Emacs. 1/* Synchronous subprocess invocation for GNU Emacs.
2 Copyright (C) 1985-1988, 1993-1995, 1999-2011 2 Copyright (C) 1985-1988, 1993-1995, 1999-2012
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -164,7 +164,8 @@ The remaining arguments are optional.
164The program's input comes from file INFILE (nil means `/dev/null'). 164The program's input comes from file INFILE (nil means `/dev/null').
165Insert output in BUFFER before point; t means current buffer; nil for BUFFER 165Insert output in BUFFER before point; t means current buffer; nil for BUFFER
166 means discard it; 0 means discard and don't wait; and `(:file FILE)', where 166 means discard it; 0 means discard and don't wait; and `(:file FILE)', where
167 FILE is a file name string, means that it should be written to that file. 167 FILE is a file name string, means that it should be written to that file
168 \(if the file already exists it is overwritten).
168BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case, 169BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
169REAL-BUFFER says what to do with standard output, as above, 170REAL-BUFFER says what to do with standard output, as above,
170while STDERR-FILE says what to do with standard error in the child. 171while STDERR-FILE says what to do with standard error in the child.
@@ -252,7 +253,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
252 val = Qraw_text; 253 val = Qraw_text;
253 else 254 else
254 { 255 {
255 SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); 256 SAFE_NALLOCA (args2, 1, nargs + 1);
256 args2[0] = Qcall_process; 257 args2[0] = Qcall_process;
257 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 258 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
258 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); 259 coding_systems = Ffind_operation_coding_system (nargs + 1, args2);
@@ -603,6 +604,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
603 604
604 /* vfork, and prevent local vars from being clobbered by the vfork. */ 605 /* vfork, and prevent local vars from being clobbered by the vfork. */
605 { 606 {
607 Lisp_Object volatile buffer_volatile = buffer;
608 Lisp_Object volatile coding_systems_volatile = coding_systems;
609 Lisp_Object volatile current_dir_volatile = current_dir;
610 int volatile fd1_volatile = fd1;
606 int volatile fd_error_volatile = fd_error; 611 int volatile fd_error_volatile = fd_error;
607 int volatile fd_output_volatile = fd_output; 612 int volatile fd_output_volatile = fd_output;
608 int volatile output_to_buffer_volatile = output_to_buffer; 613 int volatile output_to_buffer_volatile = output_to_buffer;
@@ -610,6 +615,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
610 615
611 pid = vfork (); 616 pid = vfork ();
612 617
618 buffer = buffer_volatile;
619 coding_systems = coding_systems_volatile;
620 current_dir = current_dir_volatile;
621 fd1 = fd1_volatile;
613 fd_error = fd_error_volatile; 622 fd_error = fd_error_volatile;
614 fd_output = fd_output_volatile; 623 fd_output = fd_output_volatile;
615 output_to_buffer = output_to_buffer_volatile; 624 output_to_buffer = output_to_buffer_volatile;
@@ -683,7 +692,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
683 /* Enable sending signal if user quits below. */ 692 /* Enable sending signal if user quits below. */
684 call_process_exited = 0; 693 call_process_exited = 0;
685 694
686#if defined(MSDOS) 695#if defined (MSDOS)
687 /* MSDOS needs different cleanup information. */ 696 /* MSDOS needs different cleanup information. */
688 record_unwind_protect (call_process_cleanup, 697 record_unwind_protect (call_process_cleanup,
689 Fcons (Fcurrent_buffer (), 698 Fcons (Fcurrent_buffer (),
@@ -704,6 +713,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
704 /* If BUFFER is nil, we must read process output once and then 713 /* If BUFFER is nil, we must read process output once and then
705 discard it, so setup coding system but with nil. */ 714 discard it, so setup coding system but with nil. */
706 setup_coding_system (Qnil, &process_coding); 715 setup_coding_system (Qnil, &process_coding);
716 process_coding.dst_multibyte = 0;
707 } 717 }
708 else 718 else
709 { 719 {
@@ -718,7 +728,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
718 { 728 {
719 ptrdiff_t i; 729 ptrdiff_t i;
720 730
721 SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); 731 SAFE_NALLOCA (args2, 1, nargs + 1);
722 args2[0] = Qcall_process; 732 args2[0] = Qcall_process;
723 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 733 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
724 coding_systems 734 coding_systems
@@ -739,7 +749,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
739 && !NILP (val)) 749 && !NILP (val))
740 val = raw_text_coding_system (val); 750 val = raw_text_coding_system (val);
741 setup_coding_system (val, &process_coding); 751 setup_coding_system (val, &process_coding);
752 process_coding.dst_multibyte
753 = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
742 } 754 }
755 process_coding.src_multibyte = 0;
743 756
744 immediate_quit = 1; 757 immediate_quit = 1;
745 QUIT; 758 QUIT;
@@ -928,7 +941,7 @@ Delete the text if fourth arg DELETE is non-nil.
928Insert output in BUFFER before point; t means current buffer; nil for 941Insert output in BUFFER before point; t means current buffer; nil for
929 BUFFER means discard it; 0 means discard and don't wait; and `(:file 942 BUFFER means discard it; 0 means discard and don't wait; and `(:file
930 FILE)', where FILE is a file name string, means that it should be 943 FILE)', where FILE is a file name string, means that it should be
931 written to that file. 944 written to that file (if the file already exists it is overwritten).
932BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case, 945BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
933REAL-BUFFER says what to do with standard output, as above, 946REAL-BUFFER says what to do with standard output, as above,
934while STDERR-FILE says what to do with standard error in the child. 947while STDERR-FILE says what to do with standard error in the child.
@@ -1016,7 +1029,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
1016 else 1029 else
1017 { 1030 {
1018 USE_SAFE_ALLOCA; 1031 USE_SAFE_ALLOCA;
1019 SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); 1032 SAFE_NALLOCA (args2, 1, nargs + 1);
1020 args2[0] = Qcall_process_region; 1033 args2[0] = Qcall_process_region;
1021 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1034 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1022 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); 1035 coding_systems = Ffind_operation_coding_system (nargs + 1, args2);
@@ -1145,7 +1158,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L
1145 cleaned up in the usual way. */ 1158 cleaned up in the usual way. */
1146 { 1159 {
1147 register char *temp; 1160 register char *temp;
1148 register int i; 1161 size_t i; /* size_t, because ptrdiff_t might overflow here! */
1149 1162
1150 i = SBYTES (current_dir); 1163 i = SBYTES (current_dir);
1151#ifdef MSDOS 1164#ifdef MSDOS
@@ -1307,7 +1320,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L
1307 if (err != in && err != out) 1320 if (err != in && err != out)
1308 emacs_close (err); 1321 emacs_close (err);
1309 1322
1310#if defined(USG) 1323#if defined (USG)
1311#ifndef SETPGRP_RELEASES_CTTY 1324#ifndef SETPGRP_RELEASES_CTTY
1312 setpgrp (); /* No arguments but equivalent in this case */ 1325 setpgrp (); /* No arguments but equivalent in this case */
1313#endif 1326#endif