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;
|
177
|
58 Lisp_Object Vdata_directory_list;
|
110
|
59 Lisp_Object Vconfigure_info_directory, Vsite_directory;
|
0
|
60
|
|
61 /* The default base directory XEmacs is installed under. */
|
|
62 Lisp_Object Vprefix_directory;
|
|
63
|
|
64 Lisp_Object Vshell_file_name;
|
|
65
|
|
66 /* The environment to pass to all subprocesses when they are started.
|
|
67 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... )
|
|
68 */
|
|
69 Lisp_Object Vprocess_environment;
|
|
70
|
|
71 /* True iff we are about to fork off a synchronous process or if we
|
|
72 are waiting for it. */
|
|
73 volatile int synch_process_alive;
|
|
74
|
|
75 /* Nonzero => this is a string explaining death of synchronous subprocess. */
|
|
76 CONST char *synch_process_death;
|
|
77
|
|
78 /* If synch_process_death is zero,
|
|
79 this is exit code of synchronous subprocess. */
|
|
80 int synch_process_retcode;
|
|
81
|
|
82 /* Clean up when exiting Fcall_process_internal.
|
|
83 On MSDOS, delete the temporary file on any kind of termination.
|
|
84 On Unix, kill the process and any children on termination by signal. */
|
|
85
|
|
86 /* Nonzero if this is termination due to exit. */
|
|
87 static int call_process_exited;
|
|
88
|
|
89 #ifndef VMS /* VMS version is in vmsproc.c. */
|
|
90
|
|
91 static Lisp_Object
|
|
92 call_process_kill (Lisp_Object fdpid)
|
|
93 {
|
|
94 Lisp_Object fd = Fcar (fdpid);
|
|
95 Lisp_Object pid = Fcdr (fdpid);
|
|
96
|
|
97 if (!NILP (fd))
|
|
98 close (XINT (fd));
|
|
99
|
|
100 if (!NILP (pid))
|
|
101 EMACS_KILLPG (XINT (pid), SIGKILL);
|
185
|
102
|
0
|
103 synch_process_alive = 0;
|
|
104 return Qnil;
|
|
105 }
|
|
106
|
|
107 static Lisp_Object
|
|
108 call_process_cleanup (Lisp_Object fdpid)
|
|
109 {
|
|
110 #ifdef MSDOS
|
|
111 /* for MSDOS fdpid is really (fd . tempfile) */
|
|
112 Lisp_Object file = Fcdr (fdpid);
|
|
113 close (XINT (Fcar (fdpid)));
|
14
|
114 if (strcmp (XSTRING_DATA (file), NULL_DEVICE) != 0)
|
|
115 unlink (XSTRING_DATA (file));
|
0
|
116 #else /* not MSDOS */
|
|
117 int fd = XINT (Fcar (fdpid));
|
|
118 int pid = XINT (Fcdr (fdpid));
|
|
119
|
|
120 if (!call_process_exited &&
|
|
121 EMACS_KILLPG (pid, SIGINT) == 0)
|
|
122 {
|
|
123 int speccount = specpdl_depth ();
|
|
124
|
|
125 record_unwind_protect (call_process_kill, fdpid);
|
|
126 /* #### "c-G" -- need non-consing Single-key-description */
|
|
127 message ("Waiting for process to die...(type C-g again to kill it instantly)");
|
|
128
|
|
129 /* "Discard" the unwind protect. */
|
|
130 XCAR (fdpid) = Qnil;
|
|
131 XCDR (fdpid) = Qnil;
|
|
132 unbind_to (speccount, Qnil);
|
|
133
|
|
134 message ("Waiting for process to die... done");
|
|
135 }
|
|
136 synch_process_alive = 0;
|
|
137 close (fd);
|
|
138 #endif /* not MSDOS */
|
|
139 return Qnil;
|
|
140 }
|
|
141
|
|
142 static Lisp_Object fork_error;
|
|
143 #if 0 /* UNUSED */
|
|
144 static void
|
|
145 report_fork_error (char *string, Lisp_Object data)
|
|
146 {
|
151
|
147 Lisp_Object errstring = lisp_strerror (errno);
|
0
|
148
|
|
149 fork_error = Fcons (build_string (string), Fcons (errstring, data));
|
|
150
|
|
151 /* terminate this branch of the fork, without closing stdin/out/etc. */
|
|
152 _exit (1);
|
|
153 }
|
|
154 #endif /* unused */
|
|
155
|
20
|
156 DEFUN ("call-process-internal", Fcall_process_internal, 1, MANY, 0, /*
|
0
|
157 Call PROGRAM synchronously in separate process, with coding-system specified.
|
|
158 Arguments are
|
|
159 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS).
|
|
160 The program's input comes from file INFILE (nil means `/dev/null').
|
|
161 Insert output in BUFFER before point; t means current buffer;
|
|
162 nil for BUFFER means discard it; 0 means discard and don't wait.
|
|
163 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
|
|
164 REAL-BUFFER says what to do with standard output, as above,
|
|
165 while STDERR-FILE says what to do with standard error in the child.
|
|
166 STDERR-FILE may be nil (discard standard error output),
|
|
167 t (mix it with ordinary output), or a file name string.
|
|
168
|
|
169 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
|
|
170 Remaining arguments are strings passed as command arguments to PROGRAM.
|
|
171
|
|
172 If BUFFER is 0, `call-process' returns immediately with value nil.
|
|
173 Otherwise it waits for PROGRAM to terminate and returns a numeric exit status
|
|
174 or a signal description string.
|
|
175 If you quit, the process is killed with SIGINT, or SIGKILL if you
|
|
176 quit again.
|
20
|
177 */
|
|
178 (int nargs, Lisp_Object *args))
|
0
|
179 {
|
|
180 /* This function can GC */
|
|
181 Lisp_Object infile, buffer, current_dir, display, path;
|
|
182 int fd[2];
|
|
183 int filefd;
|
|
184 int pid;
|
|
185 char buf[16384];
|
|
186 char *bufptr = buf;
|
|
187 int bufsize = 16384;
|
|
188 int speccount = specpdl_depth ();
|
116
|
189 struct gcpro gcpro1;
|
185
|
190 char **new_argv = alloca_array (char *, max (2, nargs - 2));
|
|
191
|
0
|
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 */
|
185
|
199
|
0
|
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 {
|
169
|
219 struct gcpro ngcpro1, ngcpro2;
|
185
|
220 /* Do this test before building new_argv because GC in Lisp code
|
0
|
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
|
169
|
226 NGCPRO2 (current_dir, path); /* Caller gcprotects args[] */
|
0
|
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 */
|
169
|
238 NUNGCPRO;
|
0
|
239 }
|
|
240
|
|
241 if (nargs >= 2 && ! NILP (args[1]))
|
|
242 {
|
169
|
243 struct gcpro ngcpro1;
|
|
244 NGCPRO1 (current_buffer->directory);
|
14
|
245 infile = Fexpand_file_name (args[1], current_buffer->directory);
|
169
|
246 NUNGCPRO;
|
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 }
|
185
|
288 else
|
0
|
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);
|
185
|
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);
|
185
|
329 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/')
|
0
|
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;
|
185
|
363 else
|
0
|
364 {
|
185
|
365 /* DOS can't create pipe for interprocess communication,
|
0
|
366 so redirect child process's standard output to temporary file
|
|
367 and later read the file. */
|
185
|
368
|
0
|
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
|
185
|
456 pid = child_setup (filefd, fd1, fd_error, new_argv,
|
169
|
457 (char *) XSTRING_DATA (current_dir));
|
0
|
458 #else /* not WINDOWSNT */
|
167
|
459 pid = fork ();
|
0
|
460
|
|
461 if (pid == 0)
|
|
462 {
|
|
463 if (fd[0] >= 0)
|
|
464 close (fd[0]);
|
|
465 /* This is necessary because some shells may attempt to
|
|
466 access the current controlling terminal and will hang
|
|
467 if they are run in the background, as will be the case
|
|
468 when XEmacs is started in the background. Martin
|
|
469 Buchholz observed this problem running a subprocess
|
|
470 that used zsh to call gzip to uncompress an info
|
|
471 file. */
|
|
472 disconnect_controlling_terminal ();
|
|
473 child_setup (filefd, fd1, fd_error, new_argv,
|
14
|
474 (char *) XSTRING_DATA (current_dir));
|
0
|
475 }
|
|
476 #ifdef EMACS_BTL
|
|
477 else if (logging_on)
|
|
478 cadillac_start_logging ();
|
|
479 #endif
|
|
480
|
|
481 #endif /* not MSDOS */
|
|
482 #endif /* not WINDOWSNT */
|
|
483
|
|
484 environ = save_environ;
|
|
485
|
|
486 /* Close most of our fd's, but not fd[0]
|
|
487 since we will use that to read input from. */
|
|
488 close (filefd);
|
|
489 if (fd1 >= 0)
|
|
490 close (fd1);
|
|
491 }
|
|
492
|
|
493 if (!NILP (fork_error))
|
|
494 signal_error (Qfile_error, fork_error);
|
|
495
|
|
496 if (pid < 0)
|
|
497 {
|
|
498 if (fd[0] >= 0)
|
|
499 close (fd[0]);
|
167
|
500 report_file_error ("Doing fork", Qnil);
|
0
|
501 }
|
|
502
|
|
503 if (INTP (buffer))
|
|
504 {
|
|
505 if (fd[0] >= 0)
|
|
506 close (fd[0]);
|
80
|
507 #if defined (NO_SUBPROCESSES)
|
0
|
508 /* If Emacs has been built with asynchronous subprocess support,
|
|
509 we don't need to do this, I think because it will then have
|
|
510 the facilities for handling SIGCHLD. */
|
|
511 wait_without_blocking ();
|
14
|
512 #endif /* NO_SUBPROCESSES */
|
0
|
513 return Qnil;
|
|
514 }
|
|
515
|
|
516 {
|
|
517 int nread;
|
|
518 int first = 1;
|
|
519 int total_read = 0;
|
|
520 Lisp_Object instream;
|
169
|
521 struct gcpro ngcpro1;
|
0
|
522
|
|
523 /* Enable sending signal if user quits below. */
|
|
524 call_process_exited = 0;
|
|
525
|
|
526 #ifdef MSDOS
|
|
527 /* MSDOS needs different cleanup information. */
|
|
528 record_unwind_protect (call_process_cleanup,
|
|
529 Fcons (make_int (fd[0]),
|
|
530 build_string (tempfile)));
|
14
|
531 #else /* not MSDOS */
|
0
|
532 record_unwind_protect (call_process_cleanup,
|
|
533 Fcons (make_int (fd[0]), make_int (pid)));
|
|
534 #endif /* not MSDOS */
|
|
535
|
|
536 /* FSFmacs calls Fset_buffer() here. We don't have to because
|
|
537 we can insert into buffers other than the current one. */
|
|
538 if (EQ (buffer, Qt))
|
|
539 XSETBUFFER (buffer, current_buffer);
|
|
540 instream = make_filedesc_input_stream (fd[0], 0, -1, LSTR_ALLOW_QUIT);
|
70
|
541 #ifdef MULE
|
|
542 instream =
|
|
543 make_decoding_input_stream
|
|
544 (XLSTREAM (instream),
|
120
|
545 Fget_coding_system (Vcoding_system_for_read));
|
70
|
546 Lstream_set_character_mode (XLSTREAM (instream));
|
|
547 #endif /* MULE */
|
169
|
548 NGCPRO1 (instream);
|
0
|
549 while (1)
|
|
550 {
|
|
551 QUIT;
|
|
552 /* Repeatedly read until we've filled as much as possible
|
|
553 of the buffer size we have. But don't read
|
|
554 less than 1024--save that for the next bufferfull. */
|
|
555
|
|
556 nread = 0;
|
|
557 while (nread < bufsize - 1024)
|
|
558 {
|
|
559 int this_read
|
|
560 = Lstream_read (XLSTREAM (instream), bufptr + nread,
|
|
561 bufsize - nread);
|
|
562
|
|
563 if (this_read < 0)
|
|
564 goto give_up;
|
|
565
|
|
566 if (this_read == 0)
|
|
567 goto give_up_1;
|
|
568
|
|
569 nread += this_read;
|
|
570 }
|
|
571
|
|
572 give_up_1:
|
|
573
|
|
574 /* Now NREAD is the total amount of data in the buffer. */
|
|
575 if (nread == 0)
|
|
576 break;
|
|
577
|
|
578 total_read += nread;
|
185
|
579
|
0
|
580 if (!NILP (buffer))
|
|
581 buffer_insert_raw_string (XBUFFER (buffer), (Bufbyte *) bufptr,
|
|
582 nread);
|
|
583
|
|
584 /* Make the buffer bigger as we continue to read more data,
|
|
585 but not past 64k. */
|
|
586 if (bufsize < 64 * 1024 && total_read > 32 * bufsize)
|
|
587 {
|
|
588 bufsize *= 2;
|
|
589 bufptr = (char *) alloca (bufsize);
|
|
590 }
|
|
591
|
|
592 if (!NILP (display) && INTERACTIVE)
|
|
593 {
|
|
594 first = 0;
|
|
595 redisplay ();
|
|
596 }
|
|
597 }
|
|
598 give_up:
|
|
599 Lstream_close (XLSTREAM (instream));
|
169
|
600 NUNGCPRO;
|
0
|
601
|
|
602 QUIT;
|
|
603 #ifndef MSDOS
|
|
604 /* Wait for it to terminate, unless it already has. */
|
|
605 wait_for_termination (pid);
|
|
606 #endif
|
|
607
|
|
608 /* Don't kill any children that the subprocess may have left behind
|
|
609 when exiting. */
|
|
610 call_process_exited = 1;
|
|
611 unbind_to (speccount, Qnil);
|
|
612
|
|
613 if (synch_process_death)
|
|
614 return build_string (synch_process_death);
|
|
615 return make_int (synch_process_retcode);
|
|
616 }
|
|
617 }
|
|
618
|
|
619 #endif /* VMS */
|
|
620
|
|
621 #ifndef VMS /* VMS version is in vmsproc.c. */
|
|
622
|
|
623 /* This is the last thing run in a newly forked inferior
|
|
624 either synchronous or asynchronous.
|
|
625 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2.
|
|
626 Initialize inferior's priority, pgrp, connected dir and environment.
|
|
627 then exec another program based on new_argv.
|
|
628
|
|
629 This function may change environ for the superior process.
|
|
630 Therefore, the superior process must save and restore the value
|
167
|
631 of environ around the fork and the call to this function.
|
0
|
632
|
|
633 ENV is the environment for the subprocess.
|
|
634
|
|
635 XEmacs: We've removed the SET_PGRP argument because it's already
|
|
636 done by the callers of child_setup.
|
|
637
|
|
638 CURRENT_DIR is an elisp string giving the path of the current
|
|
639 directory the subprocess should have. Since we can't really signal
|
|
640 a decent error from within the child, this should be verified as an
|
|
641 executable directory by the parent. */
|
|
642
|
|
643 static int relocate_fd (int fd, int min);
|
|
644
|
100
|
645 #ifdef WINDOWSNT
|
|
646 int
|
|
647 #else
|
0
|
648 void
|
100
|
649 #endif
|
0
|
650 child_setup (int in, int out, int err, char **new_argv,
|
|
651 CONST char *current_dir)
|
|
652 {
|
|
653 #ifdef MSDOS
|
|
654 /* The MSDOS port of gcc cannot fork, vfork, ... so we must call system
|
|
655 instead. */
|
|
656 #else /* not MSDOS */
|
|
657 char **env;
|
|
658 char *pwd;
|
|
659 #ifdef WINDOWSNT
|
|
660 int cpid;
|
|
661 HANDLE handles[4];
|
|
662 #endif /* WINDOWSNT */
|
|
663
|
|
664 #ifdef SET_EMACS_PRIORITY
|
|
665 if (emacs_priority != 0)
|
|
666 nice (- emacs_priority);
|
|
667 #endif
|
|
668
|
80
|
669 #if !defined (NO_SUBPROCESSES)
|
0
|
670 /* Close Emacs's descriptors that this process should not have. */
|
|
671 close_process_descs ();
|
20
|
672 #endif /* not NO_SUBPROCESSES */
|
0
|
673 close_load_descs ();
|
|
674
|
|
675 /* Note that use of alloca is always safe here. It's obvious for systems
|
|
676 that do not have true vfork or that have true (stack) alloca.
|
|
677 If using vfork and C_ALLOCA it is safe because that changes
|
|
678 the superior's static variables as if the superior had done alloca
|
|
679 and will be cleaned up in the usual way. */
|
|
680 {
|
|
681 REGISTER int i;
|
|
682
|
|
683 i = strlen (current_dir);
|
185
|
684 pwd = alloca_array (char, i + 6);
|
0
|
685 memcpy (pwd, "PWD=", 4);
|
|
686 memcpy (pwd + 4, current_dir, i);
|
|
687 i += 4;
|
|
688 if (!IS_DIRECTORY_SEP (pwd[i - 1]))
|
|
689 pwd[i++] = DIRECTORY_SEP;
|
|
690 pwd[i] = 0;
|
|
691
|
|
692 /* We can't signal an Elisp error here; we're in a vfork. Since
|
|
693 the callers check the current directory before forking, this
|
|
694 should only return an error if the directory's permissions
|
|
695 are changed between the check and this chdir, but we should
|
|
696 at least check. */
|
|
697 if (chdir (pwd + 4) < 0)
|
|
698 {
|
|
699 /* Don't report the chdir error, or ange-ftp.el doesn't work. */
|
|
700 /* (FSFmacs does _exit (errno) here.) */
|
|
701 pwd = 0;
|
|
702 }
|
|
703 else
|
|
704 {
|
|
705 /* Strip trailing "/". Cretinous *[]&@$#^%@#$% Un*x */
|
|
706 /* leave "//" (from FSF) */
|
|
707 while (i > 6 && IS_DIRECTORY_SEP (pwd[i - 1]))
|
|
708 pwd[--i] = 0;
|
|
709 }
|
|
710 }
|
|
711
|
|
712 /* Set `env' to a vector of the strings in Vprocess_environment. */
|
|
713 {
|
|
714 REGISTER Lisp_Object tem;
|
|
715 REGISTER char **new_env;
|
|
716 REGISTER int new_length;
|
|
717
|
|
718 new_length = 0;
|
|
719 for (tem = Vprocess_environment;
|
|
720 (CONSP (tem)
|
|
721 && STRINGP (XCAR (tem)));
|
|
722 tem = XCDR (tem))
|
|
723 new_length++;
|
|
724
|
|
725 /* new_length + 2 to include PWD and terminating 0. */
|
185
|
726 env = new_env = alloca_array (char *, new_length + 2);
|
0
|
727
|
|
728 /* If we have a PWD envvar and we know the real current directory,
|
|
729 pass one down, but with corrected value. */
|
|
730 if (pwd && getenv ("PWD"))
|
|
731 *new_env++ = pwd;
|
|
732
|
|
733 /* Copy the Vprocess_environment strings into new_env. */
|
|
734 for (tem = Vprocess_environment;
|
|
735 (CONSP (tem)
|
|
736 && STRINGP (XCAR (tem)));
|
|
737 tem = XCDR (tem))
|
|
738 {
|
|
739 char **ep = env;
|
14
|
740 char *string = (char *) XSTRING_DATA (XCAR (tem));
|
0
|
741 /* See if this string duplicates any string already in the env.
|
|
742 If so, don't put it in.
|
|
743 When an env var has multiple definitions,
|
|
744 we keep the definition that comes first in process-environment. */
|
|
745 for (; ep != new_env; ep++)
|
|
746 {
|
|
747 char *p = *ep, *q = string;
|
|
748 while (1)
|
|
749 {
|
|
750 if (*q == 0)
|
|
751 /* The string is malformed; might as well drop it. */
|
|
752 goto duplicate;
|
|
753 if (*q != *p)
|
|
754 break;
|
|
755 if (*q == '=')
|
|
756 goto duplicate;
|
|
757 p++, q++;
|
|
758 }
|
|
759 }
|
|
760 if (pwd && !strncmp ("PWD=", string, 4))
|
|
761 {
|
|
762 *new_env++ = pwd;
|
|
763 pwd = 0;
|
|
764 }
|
|
765 else
|
|
766 *new_env++ = string;
|
|
767 duplicate: ;
|
|
768 }
|
|
769 *new_env = 0;
|
|
770 }
|
|
771 #ifdef WINDOWSNT
|
|
772 prepare_standard_handles (in, out, err, handles);
|
|
773 #else /* not WINDOWSNT */
|
|
774 /* Make sure that in, out, and err are not actually already in
|
|
775 descriptors zero, one, or two; this could happen if Emacs is
|
|
776 started with its standard in, out, or error closed, as might
|
|
777 happen under X. */
|
|
778 {
|
|
779 int oin = in, oout = out;
|
|
780
|
|
781 /* We have to avoid relocating the same descriptor twice! */
|
|
782
|
|
783 in = relocate_fd (in, 3);
|
|
784
|
|
785 if (out == oin) out = in;
|
|
786 else out = relocate_fd (out, 3);
|
|
787
|
|
788 if (err == oin) err = in;
|
|
789 else if (err == oout) err = out;
|
|
790 else err = relocate_fd (err, 3);
|
|
791 }
|
|
792
|
|
793 close (0);
|
|
794 close (1);
|
|
795 close (2);
|
|
796
|
|
797 dup2 (in, 0);
|
|
798 dup2 (out, 1);
|
|
799 dup2 (err, 2);
|
185
|
800
|
0
|
801 close (in);
|
|
802 close (out);
|
|
803 close (err);
|
|
804
|
|
805 /* I can't think of any reason why child processes need any more
|
|
806 than the standard 3 file descriptors. It would be cleaner to
|
|
807 close just the ones that need to be, but the following brute
|
|
808 force approach is certainly effective, and not too slow. */
|
|
809 {
|
|
810 int fd;
|
|
811 for (fd=3; fd<=64; fd++)
|
|
812 {
|
|
813 close(fd);
|
|
814 }
|
|
815 }
|
|
816 #endif /* not WINDOWSNT */
|
|
817
|
|
818 #ifdef vipc
|
|
819 something missing here;
|
|
820 #endif /* vipc */
|
|
821
|
|
822 #ifdef WINDOWSNT
|
|
823 /* Spawn the child. (See ntproc.c:Spawnve). */
|
|
824 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env);
|
|
825 if (cpid == -1)
|
|
826 /* An error occurred while trying to spawn the process. */
|
|
827 report_file_error ("Spawning child process", Qnil);
|
|
828 reset_standard_handles (in, out, err, handles);
|
|
829 return cpid;
|
|
830 #else /* not WINDOWSNT */
|
|
831 /* execvp does not accept an environment arg so the only way
|
|
832 to pass this environment is to set environ. Our caller
|
|
833 is responsible for restoring the ambient value of environ. */
|
|
834 environ = env;
|
|
835 execvp (new_argv[0], new_argv);
|
|
836
|
|
837 stdout_out ("Cant't exec program %s\n", new_argv[0]);
|
|
838 _exit (1);
|
|
839 #endif /* not WINDOWSNT */
|
|
840 #endif /* not MSDOS */
|
|
841 }
|
|
842
|
|
843 /* Move the file descriptor FD so that its number is not less than MIN.
|
|
844 If the file descriptor is moved at all, the original is freed. */
|
|
845 static int
|
|
846 relocate_fd (int fd, int min)
|
|
847 {
|
|
848 if (fd >= min)
|
|
849 return fd;
|
|
850 else
|
|
851 {
|
|
852 int new = dup (fd);
|
|
853 if (new == -1)
|
|
854 {
|
|
855 stderr_out ("Error while setting up child: %s\n",
|
|
856 strerror (errno));
|
|
857 _exit (1);
|
|
858 }
|
|
859 /* Note that we hold the original FD open while we recurse,
|
|
860 to guarantee we'll get a new FD if we need it. */
|
|
861 new = relocate_fd (new, min);
|
|
862 close (fd);
|
|
863 return new;
|
|
864 }
|
|
865 }
|
|
866
|
|
867 static int
|
|
868 getenv_internal (CONST Bufbyte *var,
|
|
869 Bytecount varlen,
|
|
870 Bufbyte **value,
|
|
871 Bytecount *valuelen)
|
|
872 {
|
|
873 Lisp_Object scan;
|
|
874
|
|
875 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
876 {
|
|
877 Lisp_Object entry = XCAR (scan);
|
185
|
878
|
0
|
879 if (STRINGP (entry)
|
14
|
880 && XSTRING_LENGTH (entry) > varlen
|
80
|
881 && XSTRING_BYTE (entry, varlen) == '='
|
0
|
882 #ifdef WINDOWSNT
|
|
883 /* NT environment variables are case insensitive. */
|
14
|
884 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
0
|
885 #else /* not WINDOWSNT */
|
14
|
886 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
0
|
887 #endif /* not WINDOWSNT */
|
|
888 )
|
|
889 {
|
14
|
890 *value = XSTRING_DATA (entry) + (varlen + 1);
|
|
891 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1);
|
0
|
892 return 1;
|
|
893 }
|
|
894 }
|
|
895
|
|
896 return 0;
|
|
897 }
|
|
898
|
20
|
899 DEFUN ("getenv", Fgetenv, 1, 2, "sEnvironment variable: \np", /*
|
0
|
900 Return the value of environment variable VAR, as a string.
|
|
901 VAR is a string, the name of the variable.
|
|
902 When invoked interactively, prints the value in the echo area.
|
20
|
903 */
|
|
904 (var, interactivep))
|
0
|
905 {
|
|
906 Bufbyte *value;
|
|
907 Bytecount valuelen;
|
|
908 Lisp_Object v = Qnil;
|
|
909 struct gcpro gcpro1;
|
|
910
|
|
911 CHECK_STRING (var);
|
|
912 GCPRO1 (v);
|
14
|
913 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var),
|
0
|
914 &value, &valuelen))
|
|
915 v = make_string (value, valuelen);
|
|
916 if (!NILP (interactivep))
|
|
917 {
|
|
918 if (NILP (v))
|
14
|
919 message ("%s not defined in environment", XSTRING_DATA (var));
|
0
|
920 else
|
|
921 message ("\"%s\"", value);
|
|
922 }
|
|
923 RETURN_UNGCPRO (v);
|
|
924 }
|
|
925
|
|
926 /* A version of getenv that consults process_environment, easily
|
|
927 callable from C. */
|
|
928 char *
|
|
929 egetenv (CONST char *var)
|
|
930 {
|
|
931 Bufbyte *value;
|
|
932 Bytecount valuelen;
|
|
933
|
|
934 if (getenv_internal ((CONST Bufbyte *) var, strlen (var), &value, &valuelen))
|
|
935 return (char *) value;
|
|
936 else
|
|
937 return 0;
|
|
938 }
|
|
939 #endif /* not VMS */
|
|
940
|
|
941
|
|
942 void
|
|
943 init_callproc (void)
|
|
944 {
|
|
945 /* This function can GC */
|
|
946 REGISTER char *sh;
|
|
947 Lisp_Object tempdir;
|
|
948
|
|
949 Vprocess_environment = Qnil;
|
|
950 /* jwz: always initialize Vprocess_environment, so that egetenv() works
|
|
951 in temacs. */
|
|
952 {
|
|
953 char **envp;
|
|
954 for (envp = environ; envp && *envp; envp++)
|
|
955 Vprocess_environment = Fcons (build_ext_string (*envp, FORMAT_OS),
|
|
956 Vprocess_environment);
|
|
957 }
|
|
958
|
|
959 /* jwz: don't do these things when in temacs (this used to be the case by
|
|
960 virtue of egetenv() always returning 0, but that has been changed).
|
|
961 */
|
|
962 #ifndef CANNOT_DUMP
|
|
963 if (!initialized)
|
|
964 {
|
|
965 Vdata_directory = Qnil;
|
110
|
966 Vsite_directory = Qnil;
|
14
|
967 Vdoc_directory = Qnil;
|
|
968 Vexec_path = Qnil;
|
0
|
969 }
|
|
970 else
|
|
971 #endif
|
|
972 {
|
|
973 char *data_dir = egetenv ("EMACSDATA");
|
110
|
974 char *site_dir = egetenv ("EMACSSITE");
|
14
|
975 char *doc_dir = egetenv ("EMACSDOC");
|
185
|
976
|
0
|
977 #ifdef PATH_DATA
|
|
978 if (!data_dir)
|
|
979 data_dir = (char *) PATH_DATA;
|
|
980 #endif
|
|
981 #ifdef PATH_DOC
|
|
982 if (!doc_dir)
|
|
983 doc_dir = (char *) PATH_DOC;
|
|
984 #endif
|
110
|
985 #ifdef PATH_SITE
|
|
986 if (!site_dir)
|
|
987 site_dir = (char *) PATH_SITE;
|
|
988 #endif
|
185
|
989
|
0
|
990 if (data_dir)
|
|
991 Vdata_directory = Ffile_name_as_directory
|
|
992 (build_string (data_dir));
|
|
993 else
|
|
994 Vdata_directory = Qnil;
|
|
995 if (doc_dir)
|
|
996 Vdoc_directory = Ffile_name_as_directory
|
|
997 (build_string (doc_dir));
|
|
998 else
|
|
999 Vdoc_directory = Qnil;
|
110
|
1000 if (site_dir)
|
|
1001 Vsite_directory = Ffile_name_as_directory
|
|
1002 (build_string (site_dir));
|
|
1003 else
|
|
1004 Vsite_directory = Qnil;
|
0
|
1005
|
|
1006 /* Check the EMACSPATH environment variable, defaulting to the
|
|
1007 PATH_EXEC path from paths.h. */
|
|
1008 Vexec_path = decode_env_path ("EMACSPATH",
|
|
1009 #ifdef PATH_EXEC
|
|
1010 PATH_EXEC
|
|
1011 #else
|
|
1012 0
|
|
1013 #endif
|
|
1014 );
|
|
1015 }
|
|
1016
|
|
1017 if (NILP (Vexec_path))
|
|
1018 Vexec_directory = Qnil;
|
|
1019 else
|
|
1020 Vexec_directory = Ffile_name_as_directory
|
|
1021 (Fcar (Vexec_path));
|
|
1022
|
|
1023 if (initialized)
|
|
1024 Vexec_path = nconc2 (decode_env_path ("PATH", 0),
|
|
1025 Vexec_path);
|
|
1026
|
|
1027 if (!NILP (Vexec_directory))
|
|
1028 {
|
|
1029 tempdir = Fdirectory_file_name (Vexec_directory);
|
14
|
1030 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
0
|
1031 {
|
|
1032 /* If the hard-coded path is bogus, fail silently.
|
|
1033 This will allow the normal heuristics to make an attempt. */
|
|
1034 #if 0
|
|
1035 warn_when_safe
|
|
1036 (Qpath, Qwarning,
|
|
1037 "Warning: machine-dependent data dir (%s) does not exist.\n",
|
14
|
1038 XSTRING_DATA (Vexec_directory));
|
0
|
1039 #else
|
|
1040 Vexec_directory = Qnil;
|
|
1041 #endif
|
|
1042 }
|
|
1043 }
|
|
1044
|
|
1045 if (!NILP (Vdata_directory))
|
|
1046 {
|
|
1047 tempdir = Fdirectory_file_name (Vdata_directory);
|
14
|
1048 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
0
|
1049 {
|
|
1050 /* If the hard-coded path is bogus, fail silently.
|
|
1051 This will allow the normal heuristics to make an attempt. */
|
|
1052 #if 0
|
|
1053 warn_when_safe
|
|
1054 (Qpath, Qwarning,
|
|
1055 "Warning: machine-independent data dir (%s) does not exist.\n",
|
14
|
1056 XSTRING_DATA (Vdata_directory));
|
0
|
1057 #else
|
|
1058 Vdata_directory = Qnil;
|
|
1059 #endif
|
|
1060 }
|
|
1061 }
|
185
|
1062
|
110
|
1063 if (!NILP (Vsite_directory))
|
|
1064 {
|
|
1065 tempdir = Fdirectory_file_name (Vsite_directory);
|
|
1066 if (access ((char *) XSTRING_DATA (tempdir), 0) < 0)
|
|
1067 {
|
|
1068 /* If the hard-coded path is bogus, fail silently.
|
|
1069 This will allow the normal heuristics to make an attempt. */
|
|
1070 #if 0
|
|
1071 warn_when_safe
|
|
1072 (Qpath, Qwarning,
|
|
1073 "Warning: machine-independent site dir (%s) does not exist.\n",
|
|
1074 XSTRING_DATA (Vsite_directory));
|
|
1075 #else
|
|
1076 Vsite_directory = Qnil;
|
|
1077 #endif
|
|
1078 }
|
|
1079 }
|
185
|
1080
|
0
|
1081 #ifdef PATH_PREFIX
|
|
1082 Vprefix_directory = build_string ((char *) PATH_PREFIX);
|
|
1083 #else
|
|
1084 Vprefix_directory = Qnil;
|
|
1085 #endif
|
|
1086
|
|
1087 #ifdef VMS
|
|
1088 Vshell_file_name = build_string ("*dcl*");
|
179
|
1089 #elif defined(WINDOWSNT)
|
|
1090 /*
|
|
1091 ** If NT then we look at COMSPEC for the shell program.
|
|
1092 */
|
|
1093 sh = egetenv ("COMSPEC");
|
0
|
1094 {
|
|
1095 char *tem;
|
179
|
1096 /*
|
|
1097 ** If COMSPEC has been set, then convert the
|
185
|
1098 ** DOS formatted name into a UNIX format. Then
|
179
|
1099 ** create a LISP object.
|
|
1100 */
|
0
|
1101 if (sh)
|
179
|
1102 {
|
|
1103 tem = (char *) alloca (strlen (sh) + 1);
|
|
1104 dostounix_filename (strcpy (tem, sh));
|
|
1105 Vshell_file_name = build_string (tem);
|
|
1106 }
|
|
1107 /*
|
|
1108 ** Odd, no COMSPEC, so let's default to our
|
|
1109 ** best guess for NT.
|
|
1110 */
|
|
1111 else
|
|
1112 {
|
|
1113 Vshell_file_name = build_string ("/WINNT/system32/cmd.exe");
|
|
1114 }
|
0
|
1115 }
|
179
|
1116 #else /* not VMS or WINDOWSNT */
|
|
1117 sh = (char *) egetenv ("SHELL");
|
0
|
1118 Vshell_file_name = build_string (sh ? sh : "/bin/sh");
|
185
|
1119 #endif
|
0
|
1120 }
|
|
1121
|
|
1122 #if 0
|
|
1123 void
|
|
1124 set_process_environment (void)
|
|
1125 {
|
|
1126 REGISTER char **envp;
|
|
1127
|
|
1128 Vprocess_environment = Qnil;
|
|
1129 #ifndef CANNOT_DUMP
|
|
1130 if (initialized)
|
|
1131 #endif
|
|
1132 for (envp = environ; *envp; envp++)
|
|
1133 Vprocess_environment = Fcons (build_string (*envp),
|
|
1134 Vprocess_environment);
|
|
1135 }
|
|
1136 #endif /* unused */
|
|
1137
|
|
1138 void
|
|
1139 syms_of_callproc (void)
|
|
1140 {
|
|
1141 #ifndef VMS
|
20
|
1142 DEFSUBR (Fcall_process_internal);
|
|
1143 DEFSUBR (Fgetenv);
|
0
|
1144 #endif
|
|
1145 }
|
|
1146
|
|
1147 void
|
|
1148 vars_of_callproc (void)
|
|
1149 {
|
|
1150 /* This function can GC */
|
|
1151 #ifdef DOS_NT
|
|
1152 DEFVAR_LISP ("binary-process-input", &Vbinary_process_input /*
|
|
1153 *If non-nil then new subprocesses are assumed to take binary input.
|
|
1154 */ );
|
|
1155 Vbinary_process_input = Qnil;
|
|
1156
|
|
1157 DEFVAR_LISP ("binary-process-output", &Vbinary_process_output /*
|
|
1158 *If non-nil then new subprocesses are assumed to produce binary output.
|
|
1159 */ );
|
|
1160 Vbinary_process_output = Qnil;
|
|
1161 #endif /* DOS_NT */
|
|
1162
|
|
1163 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /*
|
|
1164 *File name to load inferior shells from.
|
|
1165 Initialized from the SHELL environment variable.
|
|
1166 */ );
|
|
1167
|
|
1168 DEFVAR_LISP ("exec-path", &Vexec_path /*
|
|
1169 *List of directories to search programs to run in subprocesses.
|
|
1170 Each element is a string (directory name) or nil (try default directory).
|
|
1171 */ );
|
|
1172
|
|
1173 DEFVAR_LISP ("exec-directory", &Vexec_directory /*
|
|
1174 Directory of architecture-dependent files that come with XEmacs,
|
177
|
1175 especially executable programs intended for XEmacs to invoke.
|
0
|
1176 */ );
|
|
1177
|
|
1178 DEFVAR_LISP ("data-directory", &Vdata_directory /*
|
|
1179 Directory of architecture-independent files that come with XEmacs,
|
177
|
1180 intended for XEmacs to use.
|
195
|
1181 Use of this variable in new code is almost never correct. See the
|
|
1182 function `locate-data-directory' and the variable `data-directory-list'.
|
0
|
1183 */ );
|
|
1184
|
177
|
1185 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
|
|
1186 List of directories of architecture-independent files that come with XEmacs
|
|
1187 or were installed as packages, and are intended for XEmacs to use.
|
|
1188 */ );
|
|
1189 Vdata_directory_list = Qnil;
|
|
1190
|
110
|
1191 DEFVAR_LISP ("site-directory", &Vsite_directory /*
|
|
1192 Directory of architecture-independent files that do not come with XEmacs,
|
177
|
1193 intended for XEmacs to use.
|
110
|
1194 */ );
|
|
1195
|
0
|
1196 /* FSF puts the DOC file into data-directory. They do a bunch of
|
|
1197 contortions to attempt to put everything into the DOC file
|
|
1198 whether the support is there or not. */
|
|
1199 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
|
|
1200 Directory containing the DOC file that comes with XEmacs.
|
|
1201 This is usually the same as exec-directory.
|
|
1202 */ );
|
|
1203
|
|
1204 DEFVAR_LISP ("prefix-directory", &Vprefix_directory /*
|
|
1205 The default directory under which XEmacs is installed.
|
|
1206 */ );
|
|
1207
|
|
1208 DEFVAR_LISP ("process-environment", &Vprocess_environment /*
|
|
1209 List of environment variables for subprocesses to inherit.
|
|
1210 Each element should be a string of the form ENVVARNAME=VALUE.
|
|
1211 The environment which Emacs inherits is placed in this variable
|
|
1212 when Emacs starts.
|
|
1213 */ );
|
|
1214 }
|
|
1215
|
|
1216 void
|
|
1217 complex_vars_of_callproc (void)
|
|
1218 {
|
|
1219 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
|
|
1220 For internal use by the build procedure only.
|
|
1221 This is the name of the directory in which the build procedure installed
|
|
1222 Emacs's info files; the default value for Info-default-directory-list
|
|
1223 includes this.
|
|
1224 */ );
|
|
1225 #ifdef PATH_INFO
|
|
1226 Vconfigure_info_directory =
|
|
1227 Ffile_name_as_directory (build_string (PATH_INFO));
|
|
1228 #else
|
|
1229 Vconfigure_info_directory = Qnil;
|
|
1230 #endif
|
|
1231 }
|