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