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