comparison src/callproc.c @ 209:41ff10fd062f r20-4b3

Import from CVS: tag r20-4b3
author cvs
date Mon, 13 Aug 2007 10:04:58 +0200
parents 850242ba4a81
children 78f53ef88e17
comparison
equal deleted inserted replaced
208:f427b8ec4379 209:41ff10fd062f
17 along with XEmacs; see the file COPYING. If not, write to 17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */ 19 Boston, MA 02111-1307, USA. */
20 20
21 /* Synched up with: Mule 2.0, FSF 19.30. */ 21 /* Synched up with: Mule 2.0, FSF 19.30. */
22 /* Partly sync'ed with 19.36.4 */
22 23
23 #include <config.h> 24 #include <config.h>
24 #include "lisp.h" 25 #include "lisp.h"
25 26
26 #include "buffer.h" 27 #include "buffer.h"
67 /* The environment to pass to all subprocesses when they are started. 68 /* The environment to pass to all subprocesses when they are started.
68 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... ) 69 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... )
69 */ 70 */
70 Lisp_Object Vprocess_environment; 71 Lisp_Object Vprocess_environment;
71 72
73 #ifdef DOS_NT
74 Lisp_Object Qbuffer_file_type;
75 #endif /* DOS_NT */
76
72 /* True iff we are about to fork off a synchronous process or if we 77 /* True iff we are about to fork off a synchronous process or if we
73 are waiting for it. */ 78 are waiting for it. */
74 volatile int synch_process_alive; 79 volatile int synch_process_alive;
75 80
76 /* Nonzero => this is a string explaining death of synchronous subprocess. */ 81 /* Nonzero => this is a string explaining death of synchronous subprocess. */
85 On Unix, kill the process and any children on termination by signal. */ 90 On Unix, kill the process and any children on termination by signal. */
86 91
87 /* Nonzero if this is termination due to exit. */ 92 /* Nonzero if this is termination due to exit. */
88 static int call_process_exited; 93 static int call_process_exited;
89 94
90 #ifndef VMS /* VMS version is in vmsproc.c. */
91 95
92 static Lisp_Object 96 static Lisp_Object
93 call_process_kill (Lisp_Object fdpid) 97 call_process_kill (Lisp_Object fdpid)
94 { 98 {
95 Lisp_Object fd = Fcar (fdpid); 99 Lisp_Object fd = Fcar (fdpid);
185 int pid; 189 int pid;
186 char buf[16384]; 190 char buf[16384];
187 char *bufptr = buf; 191 char *bufptr = buf;
188 int bufsize = 16384; 192 int bufsize = 16384;
189 int speccount = specpdl_depth (); 193 int speccount = specpdl_depth ();
190 struct gcpro gcpro1; 194 struct gcpro gcpro1, gcpro2;
191 char **new_argv = alloca_array (char *, max (2, nargs - 2)); 195 char **new_argv = alloca_array (char *, max (2, nargs - 2));
192 196
193 /* File to use for stderr in the child. 197 /* File to use for stderr in the child.
194 t means use same as standard output. */ 198 t means use same as standard output. */
195 Lisp_Object error_file; 199 Lisp_Object error_file;
237 Fcons (current_buffer->directory, Qnil)); 241 Fcons (current_buffer->directory, Qnil));
238 #endif /* 0 */ 242 #endif /* 0 */
239 NUNGCPRO; 243 NUNGCPRO;
240 } 244 }
241 245
246 GCPRO1 (current_dir);
247
242 if (nargs >= 2 && ! NILP (args[1])) 248 if (nargs >= 2 && ! NILP (args[1]))
243 { 249 {
244 struct gcpro ngcpro1; 250 struct gcpro ngcpro1;
245 NGCPRO1 (current_buffer->directory); 251 NGCPRO1 (current_buffer->directory);
246 infile = Fexpand_file_name (args[1], current_buffer->directory); 252 infile = Fexpand_file_name (args[1], current_buffer->directory);
248 CHECK_STRING (infile); 254 CHECK_STRING (infile);
249 } 255 }
250 else 256 else
251 infile = build_string (NULL_DEVICE); 257 infile = build_string (NULL_DEVICE);
252 258
253 GCPRO1 (infile); /* Fexpand_file_name might trash it */ 259 UNGCPRO;
260
261 GCPRO2 (infile, current_dir); /* Fexpand_file_name might trash it */
254 262
255 if (nargs >= 3) 263 if (nargs >= 3)
256 { 264 {
257 buffer = args[2]; 265 buffer = args[2];
258 266
615 return build_string (synch_process_death); 623 return build_string (synch_process_death);
616 return make_int (synch_process_retcode); 624 return make_int (synch_process_retcode);
617 } 625 }
618 } 626 }
619 627
620 #endif /* VMS */
621 628
622 #ifndef VMS /* VMS version is in vmsproc.c. */
623 629
624 /* This is the last thing run in a newly forked inferior 630 /* This is the last thing run in a newly forked inferior
625 either synchronous or asynchronous. 631 either synchronous or asynchronous.
626 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2. 632 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2.
627 Initialize inferior's priority, pgrp, connected dir and environment. 633 Initialize inferior's priority, pgrp, connected dir and environment.
769 } 775 }
770 *new_env = 0; 776 *new_env = 0;
771 } 777 }
772 #ifdef WINDOWSNT 778 #ifdef WINDOWSNT
773 prepare_standard_handles (in, out, err, handles); 779 prepare_standard_handles (in, out, err, handles);
780 set_process_dir (current_dir);
774 #else /* not WINDOWSNT */ 781 #else /* not WINDOWSNT */
775 /* Make sure that in, out, and err are not actually already in 782 /* Make sure that in, out, and err are not actually already in
776 descriptors zero, one, or two; this could happen if Emacs is 783 descriptors zero, one, or two; this could happen if Emacs is
777 started with its standard in, out, or error closed, as might 784 started with its standard in, out, or error closed, as might
778 happen under X. */ 785 happen under X. */
935 if (getenv_internal ((CONST Bufbyte *) var, strlen (var), &value, &valuelen)) 942 if (getenv_internal ((CONST Bufbyte *) var, strlen (var), &value, &valuelen))
936 return (char *) value; 943 return (char *) value;
937 else 944 else
938 return 0; 945 return 0;
939 } 946 }
940 #endif /* not VMS */
941 947
942 948
943 void 949 void
944 init_callproc (void) 950 init_callproc (void)
945 { 951 {
1083 Vprefix_directory = build_string ((char *) PATH_PREFIX); 1089 Vprefix_directory = build_string ((char *) PATH_PREFIX);
1084 #else 1090 #else
1085 Vprefix_directory = Qnil; 1091 Vprefix_directory = Qnil;
1086 #endif 1092 #endif
1087 1093
1088 #ifdef VMS 1094 #ifdef WINDOWSNT
1089 Vshell_file_name = build_string ("*dcl*"); 1095 /* Sync with FSF Emacs 19.34.6 note: this is not in 19.34.6. --marcpa */
1090 #elif defined(WINDOWSNT)
1091 /* 1096 /*
1092 ** If NT then we look at COMSPEC for the shell program. 1097 ** If NT then we look at COMSPEC for the shell program.
1093 */ 1098 */
1094 sh = egetenv ("COMSPEC"); 1099 sh = egetenv ("COMSPEC");
1095 { 1100 {
1112 else 1117 else
1113 { 1118 {
1114 Vshell_file_name = build_string ("/WINNT/system32/cmd.exe"); 1119 Vshell_file_name = build_string ("/WINNT/system32/cmd.exe");
1115 } 1120 }
1116 } 1121 }
1117 #else /* not VMS or WINDOWSNT */ 1122 #else /* not WINDOWSNT */
1118 sh = (char *) egetenv ("SHELL"); 1123 sh = (char *) egetenv ("SHELL");
1119 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); 1124 Vshell_file_name = build_string (sh ? sh : "/bin/sh");
1120 #endif 1125 #endif
1121 } 1126 }
1122 1127
1137 #endif /* unused */ 1142 #endif /* unused */
1138 1143
1139 void 1144 void
1140 syms_of_callproc (void) 1145 syms_of_callproc (void)
1141 { 1146 {
1142 #ifndef VMS
1143 DEFSUBR (Fcall_process_internal); 1147 DEFSUBR (Fcall_process_internal);
1144 DEFSUBR (Fgetenv); 1148 DEFSUBR (Fgetenv);
1145 #endif
1146 } 1149 }
1147 1150
1148 void 1151 void
1149 vars_of_callproc (void) 1152 vars_of_callproc (void)
1150 { 1153 {