0
|
1 /* Synchronous subprocess invocation for XEmacs.
|
|
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Mule 2.0, FSF 19.30. */
|
209
|
22 /* Partly sync'ed with 19.36.4 */
|
0
|
23
|
|
24 #include <config.h>
|
|
25 #include "lisp.h"
|
|
26
|
|
27 #include "buffer.h"
|
|
28 #include "commands.h"
|
|
29 #include "insdel.h"
|
|
30 #include "lstream.h"
|
159
|
31 #include <paths.h>
|
0
|
32 #include "process.h"
|
|
33 #include "sysdep.h"
|
|
34 #include "window.h"
|
259
|
35 #ifdef FILE_CODING
|
|
36 #include "file-coding.h"
|
70
|
37 #endif
|
0
|
38
|
|
39 #include "systime.h"
|
|
40 #include "sysproc.h"
|
100
|
41 #include "sysfile.h" /* Always include after sysproc.h */
|
0
|
42 #include "syssignal.h" /* Always include before systty.h */
|
|
43 #include "systty.h"
|
|
44
|
100
|
45 #ifdef WINDOWSNT
|
|
46 #define _P_NOWAIT 1 /* from process.h */
|
|
47 #endif
|
0
|
48
|
|
49 #ifdef DOS_NT
|
|
50 /* When we are starting external processes we need to know whether they
|
|
51 take binary input (no conversion) or text input (\n is converted to
|
|
52 \r\n). Similar for output: if newlines are written as \r\n then it's
|
|
53 text process output, otherwise it's binary. */
|
|
54 Lisp_Object Vbinary_process_input;
|
|
55 Lisp_Object Vbinary_process_output;
|
|
56 #endif /* DOS_NT */
|
|
57
|
|
58 Lisp_Object Vexec_path, Vexec_directory, Vdata_directory, Vdoc_directory;
|
177
|
59 Lisp_Object Vdata_directory_list;
|
110
|
60 Lisp_Object Vconfigure_info_directory, Vsite_directory;
|
203
|
61 Lisp_Object Vinfopath_internal;
|
0
|
62
|
|
63 /* The default base directory XEmacs is installed under. */
|
|
64 Lisp_Object Vprefix_directory;
|
|
65
|
|
66 Lisp_Object Vshell_file_name;
|
|
67
|
|
68 /* The environment to pass to all subprocesses when they are started.
|
|
69 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... )
|
|
70 */
|
|
71 Lisp_Object Vprocess_environment;
|
|
72
|
209
|
73 #ifdef DOS_NT
|
|
74 Lisp_Object Qbuffer_file_type;
|
|
75 #endif /* DOS_NT */
|
|
76
|
0
|
77 /* True iff we are about to fork off a synchronous process or if we
|
|
78 are waiting for it. */
|
|
79 volatile int synch_process_alive;
|
|
80
|
|
81 /* Nonzero => this is a string explaining death of synchronous subprocess. */
|
|
82 CONST char *synch_process_death;
|
|
83
|
|
84 /* If synch_process_death is zero,
|
|
85 this is exit code of synchronous subprocess. */
|
|
86 int synch_process_retcode;
|
|
87
|
|
88 /* Clean up when exiting Fcall_process_internal.
|
|
89 On MSDOS, delete the temporary file on any kind of termination.
|
|
90 On Unix, kill the process and any children on termination by signal. */
|
|
91
|
|
92 /* Nonzero if this is termination due to exit. */
|
|
93 static int call_process_exited;
|
|
94
|
|
95
|
|
96 static Lisp_Object
|
|
97 call_process_kill (Lisp_Object fdpid)
|
|
98 {
|
|
99 Lisp_Object fd = Fcar (fdpid);
|
|
100 Lisp_Object pid = Fcdr (fdpid);
|
|
101
|
|
102 if (!NILP (fd))
|
|
103 close (XINT (fd));
|
|
104
|
|
105 if (!NILP (pid))
|
|
106 EMACS_KILLPG (XINT (pid), SIGKILL);
|
185
|
107
|
0
|
108 synch_process_alive = 0;
|
|
109 return Qnil;
|
|
110 }
|
|
111
|
|
112 static Lisp_Object
|
|
113 call_process_cleanup (Lisp_Object fdpid)
|
|
114 {
|
|
115 #ifdef MSDOS
|
|
116 /* for MSDOS fdpid is really (fd . tempfile) */
|
|
117 Lisp_Object file = Fcdr (fdpid);
|
|
118 close (XINT (Fcar (fdpid)));
|
14
|
119 if (strcmp (XSTRING_DATA (file), NULL_DEVICE) != 0)
|
|
120 unlink (XSTRING_DATA (file));
|
0
|
121 #else /* not MSDOS */
|
|
122 int fd = XINT (Fcar (fdpid));
|
|
123 int pid = XINT (Fcdr (fdpid));
|
|
124
|
|
125 if (!call_process_exited &&
|
|
126 EMACS_KILLPG (pid, SIGINT) == 0)
|
|
127 {
|
|
128 int speccount = specpdl_depth ();
|
|
129
|
|
130 record_unwind_protect (call_process_kill, fdpid);
|
|
131 /* #### "c-G" -- need non-consing Single-key-description */
|
|
132 message ("Waiting for process to die...(type C-g again to kill it instantly)");
|
|
133
|
215
|
134 wait_for_termination (pid);
|
|
135
|
0
|
136 /* "Discard" the unwind protect. */
|
|
137 XCAR (fdpid) = Qnil;
|
|
138 XCDR (fdpid) = Qnil;
|
|
139 unbind_to (speccount, Qnil);
|
|
140
|
|
141 message ("Waiting for process to die... done");
|
|
142 }
|
|
143 synch_process_alive = 0;
|
|
144 close (fd);
|
|
145 #endif /* not MSDOS */
|
|
146 return Qnil;
|
|
147 }
|
|
148
|
|
149 static Lisp_Object fork_error;
|
|
150 #if 0 /* UNUSED */
|
|
151 static void
|
|
152 report_fork_error (char *string, Lisp_Object data)
|
|
153 {
|
151
|
154 Lisp_Object errstring = lisp_strerror (errno);
|
0
|
155
|
|
156 fork_error = Fcons (build_string (string), Fcons (errstring, data));
|
|
157
|
|
158 /* terminate this branch of the fork, without closing stdin/out/etc. */
|
|
159 _exit (1);
|
|
160 }
|
|
161 #endif /* unused */
|
|
162
|
20
|
163 DEFUN ("call-process-internal", Fcall_process_internal, 1, MANY, 0, /*
|
0
|
164 Call PROGRAM synchronously in separate process, with coding-system specified.
|
|
165 Arguments are
|
|
166 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS).
|
|
167 The program's input comes from file INFILE (nil means `/dev/null').
|
|
168 Insert output in BUFFER before point; t means current buffer;
|
|
169 nil for BUFFER means discard it; 0 means discard and don't wait.
|
|
170 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
|
|
171 REAL-BUFFER says what to do with standard output, as above,
|
|
172 while STDERR-FILE says what to do with standard error in the child.
|
|
173 STDERR-FILE may be nil (discard standard error output),
|
|
174 t (mix it with ordinary output), or a file name string.
|
|
175
|
|
176 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
|
|
177 Remaining arguments are strings passed as command arguments to PROGRAM.
|
|
178
|
|
179 If BUFFER is 0, `call-process' returns immediately with value nil.
|
|
180 Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
|
|
181 or a signal description string.
|
|
182 If you quit, the process is killed with SIGINT, or SIGKILL if you
|
|
183 quit again.
|
20
|
184 */
|
|
185 (int nargs, Lisp_Object *args))
|
0
|
186 {
|
|
187 /* This function can GC */
|
|
188 Lisp_Object infile, buffer, current_dir, display, path;
|
|
189 int fd[2];
|
|
190 int filefd;
|
|
191 int pid;
|
|
192 char buf[16384];
|
|
193 char *bufptr = buf;
|
|
194 int bufsize = 16384;
|
|
195 int speccount = specpdl_depth ();
|
209
|
196 struct gcpro gcpro1, gcpro2;
|
185
|
197 char **new_argv = alloca_array (char *, max (2, nargs - 2));
|
|
198
|
0
|
199 /* File to use for stderr in the child.
|
|
200 t means use same as standard output. */
|
|
201 Lisp_Object error_file;
|
|
202 #ifdef MSDOS
|
|
203 char *outf, *tempfile;
|
|
204 int outfilefd;
|
14
|
205 #endif /* MSDOS */
|
185
|
206
|
0
|
207 CHECK_STRING (args[0]);
|
|
208
|
|
209 error_file = Qt;
|
|
210
|
80
|
211 #if defined (NO_SUBPROCESSES)
|
0
|
212 /* Without asynchronous processes we cannot have BUFFER == 0. */
|
|
213 if (nargs >= 3 && !INTP (args[2]))
|
|
214 error ("Operating system cannot handle asynchronous subprocesses");
|
14
|
215 #endif /* NO_SUBPROCESSES */
|
0
|
216
|
|
217 /* Do this before building new_argv because GC in Lisp code
|
|
218 * called by various filename-hacking routines might relocate strings */
|
|
219 locate_file (Vexec_path, args[0], EXEC_SUFFIXES, &path, X_OK);
|
|
220
|
|
221 /* Make sure that the child will be able to chdir to the current
|
|
222 buffer's current directory, or its unhandled equivalent. We
|
|
223 can't just have the child check for an error when it does the
|
|
224 chdir, since it's in a vfork. */
|
|
225 {
|
169
|
226 struct gcpro ngcpro1, ngcpro2;
|
185
|
227 /* Do this test before building new_argv because GC in Lisp code
|
0
|
228 * called by various filename-hacking routines might relocate strings */
|
|
229 /* Make sure that the child will be able to chdir to the current
|
|
230 buffer's current directory. We can't just have the child check
|
|
231 for an error when it does the chdir, since it's in a vfork. */
|
|
232
|
169
|
233 NGCPRO2 (current_dir, path); /* Caller gcprotects args[] */
|
0
|
234 current_dir = current_buffer->directory;
|
116
|
235 current_dir = Funhandled_file_name_directory (current_dir);
|
|
236 current_dir = expand_and_dir_to_file (current_dir, Qnil);
|
0
|
237 #if 0
|
251
|
238 /* reportedly causes problems with ange-ftp-visited-files */
|
0
|
239 if (NILP (Ffile_accessible_directory_p (current_dir)))
|
|
240 report_file_error ("Setting current directory",
|
|
241 Fcons (current_buffer->directory, Qnil));
|
|
242 #endif /* 0 */
|
169
|
243 NUNGCPRO;
|
0
|
244 }
|
|
245
|
209
|
246 GCPRO1 (current_dir);
|
|
247
|
0
|
248 if (nargs >= 2 && ! NILP (args[1]))
|
|
249 {
|
169
|
250 struct gcpro ngcpro1;
|
|
251 NGCPRO1 (current_buffer->directory);
|
14
|
252 infile = Fexpand_file_name (args[1], current_buffer->directory);
|
169
|
253 NUNGCPRO;
|
0
|
254 CHECK_STRING (infile);
|
|
255 }
|
|
256 else
|
|
257 infile = build_string (NULL_DEVICE);
|
|
258
|
209
|
259 UNGCPRO;
|
|
260
|
|
261 GCPRO2 (infile, current_dir); /* Fexpand_file_name might trash it */
|
116
|
262
|
0
|
263 if (nargs >= 3)
|
|
264 {
|
|
265 buffer = args[2];
|
|
266
|
|
267 /* If BUFFER is a list, its meaning is
|
|
268 (BUFFER-FOR-STDOUT FILE-FOR-STDERR). */
|
|
269 if (CONSP (buffer))
|
|
270 {
|
|
271 if (CONSP (XCDR (buffer)))
|
|
272 {
|
|
273 Lisp_Object file_for_stderr = XCAR (XCDR (buffer));
|
|
274
|
|
275 if (NILP (file_for_stderr) || EQ (Qt, file_for_stderr))
|
|
276 error_file = file_for_stderr;
|
|
277 else
|
|
278 error_file = Fexpand_file_name (file_for_stderr, Qnil);
|
|
279 }
|
|
280
|
|
281 buffer = XCAR (buffer);
|
|
282 }
|
|
283
|
|
284 if (!(EQ (buffer, Qnil)
|
|
285 || EQ (buffer, Qt)
|
|
286 || ZEROP (buffer)))
|
|
287 {
|
|
288 Lisp_Object spec_buffer;
|
|
289 spec_buffer = buffer;
|
|
290 buffer = Fget_buffer (buffer);
|
|
291 /* Mention the buffer name for a better error message. */
|
|
292 if (NILP (buffer))
|
|
293 CHECK_BUFFER (spec_buffer);
|
|
294 CHECK_BUFFER (buffer);
|
|
295 }
|
|
296 }
|
185
|
297 else
|
0
|
298 buffer = Qnil;
|
|
299
|
116
|
300 UNGCPRO;
|
|
301
|
0
|
302 display = ((nargs >= 4) ? args[3] : Qnil);
|
|
303
|
14
|
304 /* From here we assume we won't GC (unless an error is signaled). */
|
0
|
305 {
|
|
306 REGISTER int i;
|
|
307 for (i = 4; i < nargs; i++)
|
|
308 {
|
|
309 CHECK_STRING (args[i]);
|
14
|
310 new_argv[i - 3] = (char *) XSTRING_DATA (args[i]);
|
0
|
311 }
|
20
|
312 new_argv[nargs - 3] = 0;
|
0
|
313 }
|
|
314
|
20
|
315 if (NILP (path))
|
|
316 report_file_error ("Searching for program", Fcons (args[0], Qnil));
|
|
317 new_argv[0] = (char *) XSTRING_DATA (path);
|
185
|
318
|
251
|
319 filefd = open ((char *) XSTRING_DATA (infile), O_RDONLY | OPEN_BINARY, 0);
|
0
|
320 if (filefd < 0)
|
20
|
321 report_file_error ("Opening process input file", Fcons (infile, Qnil));
|
0
|
322
|
|
323 #ifdef MSDOS
|
|
324 /* These vars record information from process termination.
|
|
325 Clear them now before process can possibly terminate,
|
|
326 to avoid timing error if process terminates soon. */
|
|
327 synch_process_death = 0;
|
|
328 synch_process_retcode = 0;
|
|
329
|
|
330 if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP")))
|
|
331 strcpy (tempfile = alloca (strlen (outf) + 20), outf);
|
|
332 else
|
|
333 {
|
|
334 tempfile = alloca (20);
|
|
335 *tempfile = '\0';
|
|
336 }
|
|
337 dostounix_filename (tempfile);
|
185
|
338 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/')
|
0
|
339 strcat (tempfile, "/");
|
|
340 strcat (tempfile, "detmp.XXX");
|
|
341 mktemp (tempfile);
|
|
342
|
|
343 outfilefd = creat (tempfile, S_IREAD | S_IWRITE);
|
|
344 if (outfilefd < 0)
|
|
345 {
|
|
346 close (filefd);
|
|
347 report_file_error ("Opening process output file",
|
|
348 Fcons (tempfile, Qnil));
|
|
349 }
|
14
|
350 #endif /* MSDOS */
|
0
|
351
|
|
352 #ifndef MSDOS
|
|
353 if (INTP (buffer))
|
|
354 {
|
251
|
355 fd[1] = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY, 0);
|
0
|
356 fd[0] = -1;
|
|
357 }
|
|
358 else
|
|
359 {
|
|
360 pipe (fd);
|
|
361 #if 0
|
|
362 /* Replaced by close_process_descs */
|
|
363 set_exclusive_use (fd[0]);
|
|
364 #endif
|
|
365 }
|
|
366 #else /* MSDOS */
|
|
367 {
|
|
368 char *outf;
|
|
369
|
|
370 if (INTP (buffer))
|
|
371 outf = NULL_DEVICE;
|
185
|
372 else
|
0
|
373 {
|
185
|
374 /* DOS can't create pipe for interprocess communication,
|
0
|
375 so redirect child process's standard output to temporary file
|
|
376 and later read the file. */
|
185
|
377
|
0
|
378 if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP")))
|
|
379 {
|
|
380 strcpy (tempfile, outf);
|
|
381 dostounix_filename (tempfile);
|
|
382 }
|
|
383 else
|
|
384 *tempfile = '\0';
|
|
385 if (strlen (tempfile) == 0 || tempfile[strlen (tempfile) - 1] != '/')
|
|
386 strcat (tempfile, "/");
|
|
387 strcat (tempfile, "demacs.XXX");
|
|
388 mktemp (tempfile);
|
|
389 outf = tempfile;
|
|
390 }
|
|
391
|
|
392 if ((fd[1] = creat (outf, S_IREAD | S_IWRITE)) < 0)
|
|
393 report_file_error ("Can't open temporary file", Qnil);
|
|
394 fd[0] = -1;
|
|
395 }
|
|
396 #endif /* MSDOS */
|
|
397
|
|
398 {
|
|
399 /* child_setup must clobber environ in systems with true vfork.
|
|
400 Protect it from permanent change. */
|
|
401 REGISTER char **save_environ = environ;
|
|
402 REGISTER int fd1 = fd[1];
|
|
403 int fd_error = fd1;
|
|
404 char **env;
|
|
405
|
|
406 #ifdef EMACS_BTL
|
|
407 /* when performance monitoring is on, turn it off before the vfork(),
|
|
408 as the child has no handler for the signal -- when back in the
|
|
409 parent process, turn it back on if it was really on when you "turned
|
|
410 it off" */
|
|
411 int logging_on = cadillac_stop_logging ();
|
14
|
412 #endif /* EMACS_BTL */
|
0
|
413
|
|
414 env = environ;
|
|
415
|
|
416 /* Record that we're about to create a synchronous process. */
|
|
417 synch_process_alive = 1;
|
|
418
|
|
419 /* These vars record information from process termination.
|
|
420 Clear them now before process can possibly terminate,
|
|
421 to avoid timing error if process terminates soon. */
|
|
422 synch_process_death = 0;
|
|
423 synch_process_retcode = 0;
|
|
424
|
|
425 #ifdef MSDOS
|
|
426 /* ??? Someone who knows MSDOG needs to check whether this properly
|
|
427 closes all descriptors that it opens. */
|
|
428 pid = run_msdos_command (new_argv, current_dir, filefd, outfilefd);
|
|
429 close (outfilefd);
|
|
430 fd1 = -1; /* No harm in closing that one! */
|
|
431 fd[0] = open (tempfile, NILP (Vbinary_process_output) ? O_TEXT :
|
|
432 O_BINARY);
|
|
433 if (fd[0] < 0)
|
|
434 {
|
|
435 unlink (tempfile);
|
|
436 close (filefd);
|
|
437 report_file_error ("Cannot re-open temporary file", Qnil);
|
|
438 }
|
|
439 #else /* not MSDOS */
|
|
440 if (NILP (error_file))
|
251
|
441 fd_error = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY);
|
0
|
442 else if (STRINGP (error_file))
|
|
443 {
|
|
444 #ifdef DOS_NT
|
14
|
445 fd_error = open (XSTRING_DATA (error_file),
|
0
|
446 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
|
|
447 S_IREAD | S_IWRITE);
|
|
448 #else /* not DOS_NT */
|
251
|
449 fd_error = open (XSTRING_DATA (error_file),
|
|
450 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
|
|
451 CREAT_MODE);
|
0
|
452 #endif /* not DOS_NT */
|
|
453 }
|
|
454
|
|
455 if (fd_error < 0)
|
|
456 {
|
|
457 close (filefd);
|
|
458 close (fd[0]);
|
|
459 if (fd1 >= 0)
|
|
460 close (fd1);
|
151
|
461 report_file_error ("Cannot open", Fcons(error_file, Qnil));
|
0
|
462 }
|
|
463
|
|
464 fork_error = Qnil;
|
|
465 #ifdef WINDOWSNT
|
185
|
466 pid = child_setup (filefd, fd1, fd_error, new_argv,
|
169
|
467 (char *) XSTRING_DATA (current_dir));
|
0
|
468 #else /* not WINDOWSNT */
|
167
|
469 pid = fork ();
|
0
|
470
|
|
471 if (pid == 0)
|
|
472 {
|
|
473 if (fd[0] >= 0)
|
|
474 close (fd[0]);
|
|
475 /* This is necessary because some shells may attempt to
|
|
476 access the current controlling terminal and will hang
|
|
477 if they are run in the background, as will be the case
|
|
478 when XEmacs is started in the background. Martin
|
|
479 Buchholz observed this problem running a subprocess
|
|
480 that used zsh to call gzip to uncompress an info
|
|
481 file. */
|
|
482 disconnect_controlling_terminal ();
|
|
483 child_setup (filefd, fd1, fd_error, new_argv,
|
14
|
484 (char *) XSTRING_DATA (current_dir));
|
0
|
485 }
|
|
486 #ifdef EMACS_BTL
|
|
487 else if (logging_on)
|
|
488 cadillac_start_logging ();
|
|
489 #endif
|
215
|
490 if (fd_error >= 0)
|
|
491 close (fd_error);
|
0
|
492
|
|
493 #endif /* not MSDOS */
|
|
494 #endif /* not WINDOWSNT */
|
|
495
|
|
496 environ = save_environ;
|
|
497
|
|
498 /* Close most of our fd's, but not fd[0]
|
|
499 since we will use that to read input from. */
|
|
500 close (filefd);
|
|
501 if (fd1 >= 0)
|
|
502 close (fd1);
|
|
503 }
|
|
504
|
|
505 if (!NILP (fork_error))
|
|
506 signal_error (Qfile_error, fork_error);
|
|
507
|
|
508 if (pid < 0)
|
|
509 {
|
|
510 if (fd[0] >= 0)
|
|
511 close (fd[0]);
|
167
|
512 report_file_error ("Doing fork", Qnil);
|
0
|
513 }
|
|
514
|
|
515 if (INTP (buffer))
|
|
516 {
|
|
517 if (fd[0] >= 0)
|
|
518 close (fd[0]);
|
80
|
519 #if defined (NO_SUBPROCESSES)
|
0
|
520 /* If Emacs has been built with asynchronous subprocess support,
|
|
521 we don't need to do this, I think because it will then have
|
|
522 the facilities for handling SIGCHLD. */
|
|
523 wait_without_blocking ();
|
14
|
524 #endif /* NO_SUBPROCESSES */
|
0
|
525 return Qnil;
|
|
526 }
|
|
527
|
|
528 {
|
|
529 int nread;
|
|
530 int first = 1;
|
|
531 int total_read = 0;
|
|
532 Lisp_Object instream;
|
169
|
533 struct gcpro ngcpro1;
|
0
|
534
|
|
535 /* Enable sending signal if user quits below. */
|
|
536 call_process_exited = 0;
|
|
537
|
|
538 #ifdef MSDOS
|
|
539 /* MSDOS needs different cleanup information. */
|
|
540 record_unwind_protect (call_process_cleanup,
|
|
541 Fcons (make_int (fd[0]),
|
|
542 build_string (tempfile)));
|
14
|
543 #else /* not MSDOS */
|
0
|
544 record_unwind_protect (call_process_cleanup,
|
|
545 Fcons (make_int (fd[0]), make_int (pid)));
|
|
546 #endif /* not MSDOS */
|
|
547
|
|
548 /* FSFmacs calls Fset_buffer() here. We don't have to because
|
|
549 we can insert into buffers other than the current one. */
|
|
550 if (EQ (buffer, Qt))
|
|
551 XSETBUFFER (buffer, current_buffer);
|
|
552 instream = make_filedesc_input_stream (fd[0], 0, -1, LSTR_ALLOW_QUIT);
|
259
|
553 #ifdef FILE_CODING
|
70
|
554 instream =
|
|
555 make_decoding_input_stream
|
|
556 (XLSTREAM (instream),
|
120
|
557 Fget_coding_system (Vcoding_system_for_read));
|
70
|
558 Lstream_set_character_mode (XLSTREAM (instream));
|
259
|
559 #endif
|
169
|
560 NGCPRO1 (instream);
|
0
|
561 while (1)
|
|
562 {
|
|
563 QUIT;
|
|
564 /* Repeatedly read until we've filled as much as possible
|
|
565 of the buffer size we have. But don't read
|
|
566 less than 1024--save that for the next bufferfull. */
|
|
567
|
|
568 nread = 0;
|
|
569 while (nread < bufsize - 1024)
|
|
570 {
|
|
571 int this_read
|
|
572 = Lstream_read (XLSTREAM (instream), bufptr + nread,
|
|
573 bufsize - nread);
|
|
574
|
|
575 if (this_read < 0)
|
|
576 goto give_up;
|
|
577
|
|
578 if (this_read == 0)
|
|
579 goto give_up_1;
|
|
580
|
|
581 nread += this_read;
|
|
582 }
|
|
583
|
|
584 give_up_1:
|
|
585
|
|
586 /* Now NREAD is the total amount of data in the buffer. */
|
|
587 if (nread == 0)
|
|
588 break;
|
|
589
|
213
|
590 #ifdef DOS_NT
|
|
591 /* Until we pull out of MULE things like
|
|
592 make_decoding_input_stream(), we do the following which is
|
|
593 less elegant. --marcpa */
|
|
594 {
|
215
|
595 int lf_count = 0;
|
213
|
596 if (NILP (Vbinary_process_output)) {
|
215
|
597 nread = crlf_to_lf(nread, bufptr, &lf_count);
|
213
|
598 }
|
|
599 }
|
|
600 #endif
|
|
601
|
0
|
602 total_read += nread;
|
185
|
603
|
0
|
604 if (!NILP (buffer))
|
|
605 buffer_insert_raw_string (XBUFFER (buffer), (Bufbyte *) bufptr,
|
|
606 nread);
|
|
607
|
|
608 /* Make the buffer bigger as we continue to read more data,
|
|
609 but not past 64k. */
|
|
610 if (bufsize < 64 * 1024 && total_read > 32 * bufsize)
|
|
611 {
|
|
612 bufsize *= 2;
|
|
613 bufptr = (char *) alloca (bufsize);
|
|
614 }
|
|
615
|
|
616 if (!NILP (display) && INTERACTIVE)
|
|
617 {
|
|
618 first = 0;
|
|
619 redisplay ();
|
|
620 }
|
|
621 }
|
|
622 give_up:
|
|
623 Lstream_close (XLSTREAM (instream));
|
169
|
624 NUNGCPRO;
|
0
|
625
|
|
626 QUIT;
|
|
627 #ifndef MSDOS
|
|
628 /* Wait for it to terminate, unless it already has. */
|
|
629 wait_for_termination (pid);
|
|
630 #endif
|
|
631
|
|
632 /* Don't kill any children that the subprocess may have left behind
|
|
633 when exiting. */
|
|
634 call_process_exited = 1;
|
|
635 unbind_to (speccount, Qnil);
|
|
636
|
|
637 if (synch_process_death)
|
|
638 return build_string (synch_process_death);
|
|
639 return make_int (synch_process_retcode);
|
|
640 }
|
|
641 }
|
|
642
|
|
643
|
|
644
|
|
645 /* This is the last thing run in a newly forked inferior
|
|
646 either synchronous or asynchronous.
|
|
647 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2.
|
|
648 Initialize inferior's priority, pgrp, connected dir and environment.
|
|
649 then exec another program based on new_argv.
|
|
650
|
|
651 This function may change environ for the superior process.
|
|
652 Therefore, the superior process must save and restore the value
|
167
|
653 of environ around the fork and the call to this function.
|
0
|
654
|
|
655 ENV is the environment for the subprocess.
|
|
656
|
|
657 XEmacs: We've removed the SET_PGRP argument because it's already
|
|
658 done by the callers of child_setup.
|
|
659
|
|
660 CURRENT_DIR is an elisp string giving the path of the current
|
|
661 directory the subprocess should have. Since we can't really signal
|
|
662 a decent error from within the child, this should be verified as an
|
|
663 executable directory by the parent. */
|
|
664
|
|
665 static int relocate_fd (int fd, int min);
|
|
666
|
100
|
667 #ifdef WINDOWSNT
|
|
668 int
|
|
669 #else
|
0
|
670 void
|
100
|
671 #endif
|
0
|
672 child_setup (int in, int out, int err, char **new_argv,
|
|
673 CONST char *current_dir)
|
|
674 {
|
|
675 #ifdef MSDOS
|
|
676 /* The MSDOS port of gcc cannot fork, vfork, ... so we must call system
|
|
677 instead. */
|
|
678 #else /* not MSDOS */
|
|
679 char **env;
|
|
680 char *pwd;
|
|
681 #ifdef WINDOWSNT
|
|
682 int cpid;
|
|
683 HANDLE handles[4];
|
|
684 #endif /* WINDOWSNT */
|
|
685
|
|
686 #ifdef SET_EMACS_PRIORITY
|
|
687 if (emacs_priority != 0)
|
|
688 nice (- emacs_priority);
|
|
689 #endif
|
|
690
|
80
|
691 #if !defined (NO_SUBPROCESSES)
|
0
|
692 /* Close Emacs's descriptors that this process should not have. */
|
|
693 close_process_descs ();
|
20
|
694 #endif /* not NO_SUBPROCESSES */
|
0
|
695 close_load_descs ();
|
|
696
|
|
697 /* Note that use of alloca is always safe here. It's obvious for systems
|
|
698 that do not have true vfork or that have true (stack) alloca.
|
|
699 If using vfork and C_ALLOCA it is safe because that changes
|
|
700 the superior's static variables as if the superior had done alloca
|
|
701 and will be cleaned up in the usual way. */
|
|
702 {
|
|
703 REGISTER int i;
|
|
704
|
|
705 i = strlen (current_dir);
|
185
|
706 pwd = alloca_array (char, i + 6);
|
0
|
707 memcpy (pwd, "PWD=", 4);
|
|
708 memcpy (pwd + 4, current_dir, i);
|
|
709 i += 4;
|
|
710 if (!IS_DIRECTORY_SEP (pwd[i - 1]))
|
|
711 pwd[i++] = DIRECTORY_SEP;
|
|
712 pwd[i] = 0;
|
|
713
|
|
714 /* We can't signal an Elisp error here; we're in a vfork. Since
|
|
715 the callers check the current directory before forking, this
|
|
716 should only return an error if the directory's permissions
|
|
717 are changed between the check and this chdir, but we should
|
|
718 at least check. */
|
|
719 if (chdir (pwd + 4) < 0)
|
|
720 {
|
|
721 /* Don't report the chdir error, or ange-ftp.el doesn't work. */
|
|
722 /* (FSFmacs does _exit (errno) here.) */
|
|
723 pwd = 0;
|
|
724 }
|
|
725 else
|
|
726 {
|
|
727 /* Strip trailing "/". Cretinous *[]&@$#^%@#$% Un*x */
|
|
728 /* leave "//" (from FSF) */
|
|
729 while (i > 6 && IS_DIRECTORY_SEP (pwd[i - 1]))
|
|
730 pwd[--i] = 0;
|
|
731 }
|
|
732 }
|
|
733
|
|
734 /* Set `env' to a vector of the strings in Vprocess_environment. */
|
|
735 {
|
|
736 REGISTER Lisp_Object tem;
|
|
737 REGISTER char **new_env;
|
|
738 REGISTER int new_length;
|
|
739
|
|
740 new_length = 0;
|
|
741 for (tem = Vprocess_environment;
|
|
742 (CONSP (tem)
|
|
743 && STRINGP (XCAR (tem)));
|
|
744 tem = XCDR (tem))
|
|
745 new_length++;
|
|
746
|
|
747 /* new_length + 2 to include PWD and terminating 0. */
|
185
|
748 env = new_env = alloca_array (char *, new_length + 2);
|
0
|
749
|
|
750 /* If we have a PWD envvar and we know the real current directory,
|
|
751 pass one down, but with corrected value. */
|
|
752 if (pwd && getenv ("PWD"))
|
|
753 *new_env++ = pwd;
|
|
754
|
|
755 /* Copy the Vprocess_environment strings into new_env. */
|
|
756 for (tem = Vprocess_environment;
|
|
757 (CONSP (tem)
|
|
758 && STRINGP (XCAR (tem)));
|
|
759 tem = XCDR (tem))
|
|
760 {
|
|
761 char **ep = env;
|
14
|
762 char *string = (char *) XSTRING_DATA (XCAR (tem));
|
0
|
763 /* See if this string duplicates any string already in the env.
|
|
764 If so, don't put it in.
|
|
765 When an env var has multiple definitions,
|
|
766 we keep the definition that comes first in process-environment. */
|
|
767 for (; ep != new_env; ep++)
|
|
768 {
|
|
769 char *p = *ep, *q = string;
|
|
770 while (1)
|
|
771 {
|
|
772 if (*q == 0)
|
|
773 /* The string is malformed; might as well drop it. */
|
|
774 goto duplicate;
|
|
775 if (*q != *p)
|
|
776 break;
|
|
777 if (*q == '=')
|
|
778 goto duplicate;
|
|
779 p++, q++;
|
|
780 }
|
|
781 }
|
|
782 if (pwd && !strncmp ("PWD=", string, 4))
|
|
783 {
|
|
784 *new_env++ = pwd;
|
|
785 pwd = 0;
|
|
786 }
|
|
787 else
|
|
788 *new_env++ = string;
|
|
789 duplicate: ;
|
|
790 }
|
|
791 *new_env = 0;
|
|
792 }
|
|
793 #ifdef WINDOWSNT
|
|
794 prepare_standard_handles (in, out, err, handles);
|
209
|
795 set_process_dir (current_dir);
|
0
|
796 #else /* not WINDOWSNT */
|
|
797 /* Make sure that in, out, and err are not actually already in
|
|
798 descriptors zero, one, or two; this could happen if Emacs is
|
|
799 started with its standard in, out, or error closed, as might
|
|
800 happen under X. */
|
|
801 {
|
|
802 int oin = in, oout = out;
|
|
803
|
|
804 /* We have to avoid relocating the same descriptor twice! */
|
|
805
|
|
806 in = relocate_fd (in, 3);
|
|
807
|
|
808 if (out == oin) out = in;
|
|
809 else out = relocate_fd (out, 3);
|
|
810
|
|
811 if (err == oin) err = in;
|
|
812 else if (err == oout) err = out;
|
|
813 else err = relocate_fd (err, 3);
|
|
814 }
|
|
815
|
|
816 close (0);
|
|
817 close (1);
|
|
818 close (2);
|
|
819
|
|
820 dup2 (in, 0);
|
|
821 dup2 (out, 1);
|
|
822 dup2 (err, 2);
|
185
|
823
|
0
|
824 close (in);
|
|
825 close (out);
|
|
826 close (err);
|
|
827
|
|
828 /* I can't think of any reason why child processes need any more
|
|
829 than the standard 3 file descriptors. It would be cleaner to
|
|
830 close just the ones that need to be, but the following brute
|
|
831 force approach is certainly effective, and not too slow. */
|
|
832 {
|
|
833 int fd;
|
|
834 for (fd=3; fd<=64; fd++)
|
|
835 {
|
|
836 close(fd);
|
|
837 }
|
|
838 }
|
|
839 #endif /* not WINDOWSNT */
|
|
840
|
|
841 #ifdef vipc
|
|
842 something missing here;
|
|
843 #endif /* vipc */
|
|
844
|
|
845 #ifdef WINDOWSNT
|
|
846 /* Spawn the child. (See ntproc.c:Spawnve). */
|
|
847 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env);
|
|
848 if (cpid == -1)
|
|
849 /* An error occurred while trying to spawn the process. */
|
|
850 report_file_error ("Spawning child process", Qnil);
|
|
851 reset_standard_handles (in, out, err, handles);
|
|
852 return cpid;
|
|
853 #else /* not WINDOWSNT */
|
|
854 /* execvp does not accept an environment arg so the only way
|
|
855 to pass this environment is to set environ. Our caller
|
|
856 is responsible for restoring the ambient value of environ. */
|
|
857 environ = env;
|
|
858 execvp (new_argv[0], new_argv);
|
|
859
|
|
860 stdout_out ("Cant't exec program %s\n", new_argv[0]);
|
|
861 _exit (1);
|
|
862 #endif /* not WINDOWSNT */
|
|
863 #endif /* not MSDOS */
|
|
864 }
|
|
865
|
|
866 /* Move the file descriptor FD so that its number is not less than MIN.
|
|
867 If the file descriptor is moved at all, the original is freed. */
|
|
868 static int
|
|
869 relocate_fd (int fd, int min)
|
|
870 {
|
|
871 if (fd >= min)
|
|
872 return fd;
|
|
873 else
|
|
874 {
|
|
875 int new = dup (fd);
|
|
876 if (new == -1)
|
|
877 {
|
|
878 stderr_out ("Error while setting up child: %s\n",
|
|
879 strerror (errno));
|
|
880 _exit (1);
|
|
881 }
|
|
882 /* Note that we hold the original FD open while we recurse,
|
|
883 to guarantee we'll get a new FD if we need it. */
|
|
884 new = relocate_fd (new, min);
|
|
885 close (fd);
|
|
886 return new;
|
|
887 }
|
|
888 }
|
|
889
|
|
890 static int
|
|
891 getenv_internal (CONST Bufbyte *var,
|
|
892 Bytecount varlen,
|
|
893 Bufbyte **value,
|
|
894 Bytecount *valuelen)
|
|
895 {
|
|
896 Lisp_Object scan;
|
|
897
|
|
898 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
899 {
|
|
900 Lisp_Object entry = XCAR (scan);
|
185
|
901
|
0
|
902 if (STRINGP (entry)
|
14
|
903 && XSTRING_LENGTH (entry) > varlen
|
80
|
904 && XSTRING_BYTE (entry, varlen) == '='
|
0
|
905 #ifdef WINDOWSNT
|
|
906 /* NT environment variables are case insensitive. */
|
14
|
907 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
0
|
908 #else /* not WINDOWSNT */
|
14
|
909 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
0
|
910 #endif /* not WINDOWSNT */
|
|
911 )
|
|
912 {
|
14
|
913 *value = XSTRING_DATA (entry) + (varlen + 1);
|
|
914 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1);
|
0
|
915 return 1;
|
|
916 }
|
|
917 }
|
|
918
|
|
919 return 0;
|
|
920 }
|
|
921
|
20
|
922 DEFUN ("getenv", Fgetenv, 1, 2, "sEnvironment variable: \np", /*
|
0
|
923 Return the value of environment variable VAR, as a string.
|
|
924 VAR is a string, the name of the variable.
|
|
925 When invoked interactively, prints the value in the echo area.
|
20
|
926 */
|
|
927 (var, interactivep))
|
0
|
928 {
|
|
929 Bufbyte *value;
|
|
930 Bytecount valuelen;
|
|
931 Lisp_Object v = Qnil;
|
|
932 struct gcpro gcpro1;
|
|
933
|
|
934 CHECK_STRING (var);
|
|
935 GCPRO1 (v);
|
14
|
936 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var),
|
0
|
937 &value, &valuelen))
|
|
938 v = make_string (value, valuelen);
|
|
939 if (!NILP (interactivep))
|
|
940 {
|
|
941 if (NILP (v))
|
14
|
942 message ("%s not defined in environment", XSTRING_DATA (var));
|
0
|
943 else
|
|
944 message ("\"%s\"", value);
|
|
945 }
|
|
946 RETURN_UNGCPRO (v);
|
|
947 }
|
|
948
|
|
949 /* A version of getenv that consults process_environment, easily
|
|
950 callable from C. */
|
|
951 char *
|
|
952 egetenv (CONST char *var)
|
|
953 {
|
|
954 Bufbyte *value;
|
|
955 Bytecount valuelen;
|
|
956
|
|
957 if (getenv_internal ((CONST Bufbyte *) var, strlen (var), &value, &valuelen))
|
|
958 return (char *) value;
|
|
959 else
|
|
960 return 0;
|
|
961 }
|
|
962
|
|
963
|
|
964 void
|
|
965 init_callproc (void)
|
|
966 {
|
|
967 /* This function can GC */
|
|
968 REGISTER char *sh;
|
|
969 Lisp_Object tempdir;
|
|
970
|
|
971 Vprocess_environment = Qnil;
|
|
972 /* jwz: always initialize Vprocess_environment, so that egetenv() works
|
|
973 in temacs. */
|
|
974 {
|
|
975 char **envp;
|
|
976 for (envp = environ; envp && *envp; envp++)
|
259
|
977 {
|
|
978 Vprocess_environment = Fcons (build_ext_string (*envp, FORMAT_OS),
|
|
979 Vprocess_environment);
|
|
980 }
|
0
|
981 }
|
|
982
|
|
983 /* jwz: don't do these things when in temacs (this used to be the case by
|
|
984 virtue of egetenv() always returning 0, but that has been changed).
|
|
985 */
|
|
986 #ifndef CANNOT_DUMP
|
|
987 if (!initialized)
|
|
988 {
|
|
989 Vdata_directory = Qnil;
|
110
|
990 Vsite_directory = Qnil;
|
14
|
991 Vdoc_directory = Qnil;
|
|
992 Vexec_path = Qnil;
|
0
|
993 }
|
|
994 else
|
|
995 #endif
|
|
996 {
|
|
997 char *data_dir = egetenv ("EMACSDATA");
|
110
|
998 char *site_dir = egetenv ("EMACSSITE");
|
14
|
999 char *doc_dir = egetenv ("EMACSDOC");
|
185
|
1000
|
0
|
1001 #ifdef PATH_DATA
|
|
1002 if (!data_dir)
|
|
1003 data_dir = (char *) PATH_DATA;
|
|
1004 #endif
|
|
1005 #ifdef PATH_DOC
|
|
1006 if (!doc_dir)
|
|
1007 doc_dir = (char *) PATH_DOC;
|
|
1008 #endif
|
110
|
1009 #ifdef PATH_SITE
|
|
1010 if (!site_dir)
|
|
1011 site_dir = (char *) PATH_SITE;
|
|
1012 #endif
|
185
|
1013
|
0
|
1014 if (data_dir)
|
|
1015 Vdata_directory = Ffile_name_as_directory
|
|
1016 (build_string (data_dir));
|
|
1017 else
|
|
1018 Vdata_directory = Qnil;
|
|
1019 if (doc_dir)
|
|
1020 Vdoc_directory = Ffile_name_as_directory
|
|
1021 (build_string (doc_dir));
|
|
1022 else
|
|
1023 Vdoc_directory = Qnil;
|
110
|
1024 if (site_dir)
|
|
1025 Vsite_directory = Ffile_name_as_directory
|
|
1026 (build_string (site_dir));
|
|
1027 else
|
|
1028 Vsite_directory = Qnil;
|
0
|
1029
|
|
1030 /* Check the EMACSPATH environment variable, defaulting to the
|
|
1031 PATH_EXEC path from paths.h. */
|
|
1032 Vexec_path = decode_env_path ("EMACSPATH",
|
|
1033 #ifdef PATH_EXEC
|
|
1034 PATH_EXEC
|
|
1035 #else
|
|
1036 0
|
|
1037 #endif
|
|
1038 );
|
|
1039 }
|
|
1040
|
|
1041 if (NILP (Vexec_path))
|
|
1042 Vexec_directory = Qnil;
|
|
1043 else
|
|
1044 Vexec_directory = Ffile_name_as_directory
|
|
1045 (Fcar (Vexec_path));
|
|
1046
|
|
1047 if (initialized)
|
|
1048 Vexec_path = nconc2 (decode_env_path ("PATH", 0),
|
|
1049 Vexec_path);
|
|
1050
|
|
1051 if (!NILP (Vexec_directory))
|
|
1052 {
|
|
1053 tempdir = Fdirectory_file_name (Vexec_directory);
|
14
|
1054 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
0
|
1055 {
|
|
1056 /* If the hard-coded path is bogus, fail silently.
|
|
1057 This will allow the normal heuristics to make an attempt. */
|
|
1058 #if 0
|
|
1059 warn_when_safe
|
|
1060 (Qpath, Qwarning,
|
|
1061 "Warning: machine-dependent data dir (%s) does not exist.\n",
|
14
|
1062 XSTRING_DATA (Vexec_directory));
|
0
|
1063 #else
|
|
1064 Vexec_directory = Qnil;
|
|
1065 #endif
|
|
1066 }
|
|
1067 }
|
|
1068
|
|
1069 if (!NILP (Vdata_directory))
|
|
1070 {
|
|
1071 tempdir = Fdirectory_file_name (Vdata_directory);
|
14
|
1072 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
0
|
1073 {
|
|
1074 /* If the hard-coded path is bogus, fail silently.
|
|
1075 This will allow the normal heuristics to make an attempt. */
|
|
1076 #if 0
|
|
1077 warn_when_safe
|
|
1078 (Qpath, Qwarning,
|
|
1079 "Warning: machine-independent data dir (%s) does not exist.\n",
|
14
|
1080 XSTRING_DATA (Vdata_directory));
|
0
|
1081 #else
|
|
1082 Vdata_directory = Qnil;
|
|
1083 #endif
|
|
1084 }
|
|
1085 }
|
185
|
1086
|
110
|
1087 if (!NILP (Vsite_directory))
|
|
1088 {
|
|
1089 tempdir = Fdirectory_file_name (Vsite_directory);
|
|
1090 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
|
1091 {
|
|
1092 /* If the hard-coded path is bogus, fail silently.
|
|
1093 This will allow the normal heuristics to make an attempt. */
|
|
1094 #if 0
|
|
1095 warn_when_safe
|
|
1096 (Qpath, Qwarning,
|
|
1097 "Warning: machine-independent site dir (%s) does not exist.\n",
|
|
1098 XSTRING_DATA (Vsite_directory));
|
|
1099 #else
|
|
1100 Vsite_directory = Qnil;
|
|
1101 #endif
|
|
1102 }
|
|
1103 }
|
185
|
1104
|
0
|
1105 #ifdef PATH_PREFIX
|
|
1106 Vprefix_directory = build_string ((char *) PATH_PREFIX);
|
|
1107 #else
|
|
1108 Vprefix_directory = Qnil;
|
|
1109 #endif
|
|
1110
|
209
|
1111 #ifdef WINDOWSNT
|
|
1112 /* Sync with FSF Emacs 19.34.6 note: this is not in 19.34.6. --marcpa */
|
179
|
1113 /*
|
|
1114 ** If NT then we look at COMSPEC for the shell program.
|
|
1115 */
|
|
1116 sh = egetenv ("COMSPEC");
|
0
|
1117 {
|
|
1118 char *tem;
|
179
|
1119 /*
|
|
1120 ** If COMSPEC has been set, then convert the
|
185
|
1121 ** DOS formatted name into a UNIX format. Then
|
179
|
1122 ** create a LISP object.
|
|
1123 */
|
0
|
1124 if (sh)
|
179
|
1125 {
|
|
1126 tem = (char *) alloca (strlen (sh) + 1);
|
|
1127 dostounix_filename (strcpy (tem, sh));
|
|
1128 Vshell_file_name = build_string (tem);
|
|
1129 }
|
|
1130 /*
|
|
1131 ** Odd, no COMSPEC, so let's default to our
|
|
1132 ** best guess for NT.
|
|
1133 */
|
|
1134 else
|
|
1135 {
|
|
1136 Vshell_file_name = build_string ("/WINNT/system32/cmd.exe");
|
|
1137 }
|
0
|
1138 }
|
209
|
1139 #else /* not WINDOWSNT */
|
179
|
1140 sh = (char *) egetenv ("SHELL");
|
0
|
1141 Vshell_file_name = build_string (sh ? sh : "/bin/sh");
|
185
|
1142 #endif
|
0
|
1143 }
|
|
1144
|
|
1145 #if 0
|
|
1146 void
|
|
1147 set_process_environment (void)
|
|
1148 {
|
|
1149 REGISTER char **envp;
|
|
1150
|
|
1151 Vprocess_environment = Qnil;
|
|
1152 #ifndef CANNOT_DUMP
|
|
1153 if (initialized)
|
|
1154 #endif
|
|
1155 for (envp = environ; *envp; envp++)
|
|
1156 Vprocess_environment = Fcons (build_string (*envp),
|
|
1157 Vprocess_environment);
|
|
1158 }
|
|
1159 #endif /* unused */
|
|
1160
|
|
1161 void
|
|
1162 syms_of_callproc (void)
|
|
1163 {
|
20
|
1164 DEFSUBR (Fcall_process_internal);
|
|
1165 DEFSUBR (Fgetenv);
|
0
|
1166 }
|
|
1167
|
|
1168 void
|
|
1169 vars_of_callproc (void)
|
|
1170 {
|
|
1171 /* This function can GC */
|
|
1172 #ifdef DOS_NT
|
|
1173 DEFVAR_LISP ("binary-process-input", &Vbinary_process_input /*
|
|
1174 *If non-nil then new subprocesses are assumed to take binary input.
|
|
1175 */ );
|
|
1176 Vbinary_process_input = Qnil;
|
|
1177
|
|
1178 DEFVAR_LISP ("binary-process-output", &Vbinary_process_output /*
|
|
1179 *If non-nil then new subprocesses are assumed to produce binary output.
|
|
1180 */ );
|
|
1181 Vbinary_process_output = Qnil;
|
|
1182 #endif /* DOS_NT */
|
|
1183
|
|
1184 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /*
|
|
1185 *File name to load inferior shells from.
|
|
1186 Initialized from the SHELL environment variable.
|
|
1187 */ );
|
|
1188
|
|
1189 DEFVAR_LISP ("exec-path", &Vexec_path /*
|
|
1190 *List of directories to search programs to run in subprocesses.
|
|
1191 Each element is a string (directory name) or nil (try default directory).
|
|
1192 */ );
|
|
1193
|
|
1194 DEFVAR_LISP ("exec-directory", &Vexec_directory /*
|
|
1195 Directory of architecture-dependent files that come with XEmacs,
|
177
|
1196 especially executable programs intended for XEmacs to invoke.
|
0
|
1197 */ );
|
|
1198
|
|
1199 DEFVAR_LISP ("data-directory", &Vdata_directory /*
|
|
1200 Directory of architecture-independent files that come with XEmacs,
|
177
|
1201 intended for XEmacs to use.
|
195
|
1202 Use of this variable in new code is almost never correct. See the
|
|
1203 function `locate-data-directory' and the variable `data-directory-list'.
|
0
|
1204 */ );
|
|
1205
|
177
|
1206 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
|
|
1207 List of directories of architecture-independent files that come with XEmacs
|
|
1208 or were installed as packages, and are intended for XEmacs to use.
|
|
1209 */ );
|
|
1210 Vdata_directory_list = Qnil;
|
|
1211
|
110
|
1212 DEFVAR_LISP ("site-directory", &Vsite_directory /*
|
|
1213 Directory of architecture-independent files that do not come with XEmacs,
|
177
|
1214 intended for XEmacs to use.
|
110
|
1215 */ );
|
|
1216
|
0
|
1217 /* FSF puts the DOC file into data-directory. They do a bunch of
|
|
1218 contortions to attempt to put everything into the DOC file
|
|
1219 whether the support is there or not. */
|
|
1220 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
|
|
1221 Directory containing the DOC file that comes with XEmacs.
|
|
1222 This is usually the same as exec-directory.
|
|
1223 */ );
|
|
1224
|
|
1225 DEFVAR_LISP ("prefix-directory", &Vprefix_directory /*
|
|
1226 The default directory under which XEmacs is installed.
|
|
1227 */ );
|
|
1228
|
|
1229 DEFVAR_LISP ("process-environment", &Vprocess_environment /*
|
|
1230 List of environment variables for subprocesses to inherit.
|
|
1231 Each element should be a string of the form ENVVARNAME=VALUE.
|
|
1232 The environment which Emacs inherits is placed in this variable
|
|
1233 when Emacs starts.
|
|
1234 */ );
|
|
1235 }
|
|
1236
|
|
1237 void
|
|
1238 complex_vars_of_callproc (void)
|
|
1239 {
|
|
1240 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
|
|
1241 For internal use by the build procedure only.
|
|
1242 This is the name of the directory in which the build procedure installed
|
|
1243 Emacs's info files; the default value for Info-default-directory-list
|
|
1244 includes this.
|
|
1245 */ );
|
203
|
1246
|
0
|
1247 #ifdef PATH_INFO
|
|
1248 Vconfigure_info_directory =
|
|
1249 Ffile_name_as_directory (build_string (PATH_INFO));
|
|
1250 #else
|
|
1251 Vconfigure_info_directory = Qnil;
|
|
1252 #endif
|
203
|
1253
|
|
1254 DEFVAR_LISP ("infopath-internal", &Vinfopath_internal /*
|
|
1255 The configured initial value of Info-default-directory-list.
|
|
1256 */ );
|
|
1257
|
|
1258 #ifdef PATH_INFOPATH
|
|
1259 Vinfopath_internal = build_string (PATH_INFOPATH);
|
|
1260 #else
|
|
1261 Vinfopath_internal =
|
|
1262 build_string ("/usr/info:/usr/local/info:/usr/lib/texmf/doc/info:/usr/local/lib/texmf/doc/info");
|
|
1263 #endif
|
0
|
1264 }
|