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