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