Mercurial > emacs
annotate src/callproc.c @ 14118:e7809b53da4d
(mh-display-msg): Use kill-local-variable
to clear out write-contents-hooks.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 09 Jan 1996 23:19:28 +0000 |
parents | 621a575db6f7 |
children | ee40177f6c68 |
rev | line source |
---|---|
296 | 1 /* Synchronous subprocess invocation for GNU Emacs. |
11235 | 2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc. |
296 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
296 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include <signal.h> | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
22 #include <errno.h> |
296 | 23 |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
3932
diff
changeset
|
24 #include <config.h> |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7824
diff
changeset
|
25 #include <stdio.h> |
296 | 26 |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
27 extern int errno; |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
28 extern char *strerror (); |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
29 |
296 | 30 /* Define SIGCHLD as an alias for SIGCLD. */ |
31 | |
32 #if !defined (SIGCHLD) && defined (SIGCLD) | |
33 #define SIGCHLD SIGCLD | |
34 #endif /* SIGCLD */ | |
35 | |
36 #include <sys/types.h> | |
3932
9a411d86ca72
(PRIO_PROCESS): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
3826
diff
changeset
|
37 |
296 | 38 #include <sys/file.h> |
39 #ifdef USG5 | |
6818
6a9b0b5399ce
If we include fcntl.h, define INCLUDED_FCNTL.
Richard M. Stallman <rms@gnu.org>
parents:
6614
diff
changeset
|
40 #define INCLUDED_FCNTL |
296 | 41 #include <fcntl.h> |
42 #endif | |
43 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
44 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
45 #define NOMINMAX |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
46 #include <windows.h> |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
47 #include <stdlib.h> /* for proper declaration of environ */ |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
48 #include <fcntl.h> |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
49 #include "nt.h" |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
50 #define _P_NOWAIT 1 /* from process.h */ |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
51 #endif |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
52 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
53 #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ |
7782
5fc8a3a9539a
[MSDOS]: #include "msdos.h" for rootrelativepath template.
Karl Heuer <kwzh@gnu.org>
parents:
7722
diff
changeset
|
54 #include "msdos.h" |
6818
6a9b0b5399ce
If we include fcntl.h, define INCLUDED_FCNTL.
Richard M. Stallman <rms@gnu.org>
parents:
6614
diff
changeset
|
55 #define INCLUDED_FCNTL |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
56 #include <fcntl.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
57 #include <sys/stat.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
58 #include <sys/param.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
59 #include <errno.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
60 #endif /* MSDOS */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
61 |
296 | 62 #ifndef O_RDONLY |
63 #define O_RDONLY 0 | |
64 #endif | |
65 | |
66 #ifndef O_WRONLY | |
67 #define O_WRONLY 1 | |
68 #endif | |
69 | |
70 #include "lisp.h" | |
71 #include "commands.h" | |
72 #include "buffer.h" | |
4701
05f6a91c2801
Include <paths.h>, not "paths.h".
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
73 #include <paths.h> |
296 | 74 #include "process.h" |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
75 #include "syssignal.h" |
5348 | 76 #include "systty.h" |
296 | 77 |
78 #ifdef VMS | |
79 extern noshare char **environ; | |
80 #else | |
81 extern char **environ; | |
82 #endif | |
83 | |
84 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
85 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
86 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
87 /* When we are starting external processes we need to know whether they |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
88 take binary input (no conversion) or text input (\n is converted to |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
89 \r\n). Similar for output: if newlines are written as \r\n then it's |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
90 text process output, otherwise it's binary. */ |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
91 Lisp_Object Vbinary_process_input; |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
92 Lisp_Object Vbinary_process_output; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
93 #endif /* DOS_NT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
94 |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
95 Lisp_Object Vexec_path, Vexec_directory, Vdata_directory, Vdoc_directory; |
3064
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
96 Lisp_Object Vconfigure_info_directory; |
296 | 97 |
98 Lisp_Object Vshell_file_name; | |
99 | |
100 Lisp_Object Vprocess_environment; | |
101 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
102 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
103 Lisp_Object Qbuffer_file_type; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
104 #endif /* DOS_NT */ |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
105 |
296 | 106 /* True iff we are about to fork off a synchronous process or if we |
107 are waiting for it. */ | |
108 int synch_process_alive; | |
109 | |
110 /* Nonzero => this is a string explaining death of synchronous subprocess. */ | |
111 char *synch_process_death; | |
112 | |
113 /* If synch_process_death is zero, | |
114 this is exit code of synchronous subprocess. */ | |
115 int synch_process_retcode; | |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
116 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
117 extern Lisp_Object Vdoc_file_name; |
296 | 118 |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
119 /* Clean up when exiting Fcall_process. |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
120 On MSDOS, delete the temporary file on any kind of termination. |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
121 On Unix, kill the process and any children on termination by signal. */ |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
122 |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
123 /* Nonzero if this is termination due to exit. */ |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
124 static int call_process_exited; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
125 |
296 | 126 #ifndef VMS /* VMS version is in vmsproc.c. */ |
127 | |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
128 static Lisp_Object |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
129 call_process_kill (fdpid) |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
130 Lisp_Object fdpid; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
131 { |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
132 close (XFASTINT (Fcar (fdpid))); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
133 EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
134 synch_process_alive = 0; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
135 return Qnil; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
136 } |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
137 |
296 | 138 Lisp_Object |
139 call_process_cleanup (fdpid) | |
140 Lisp_Object fdpid; | |
141 { | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
142 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
143 /* for MSDOS fdpid is really (fd . tempfile) */ |
6495
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
144 register Lisp_Object file; |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
145 file = Fcdr (fdpid); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
146 close (XFASTINT (Fcar (fdpid))); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
147 if (strcmp (XSTRING (file)-> data, NULL_DEVICE) != 0) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
148 unlink (XSTRING (file)->data); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
149 #else /* not MSDOS */ |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
150 register int pid = XFASTINT (Fcdr (fdpid)); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
151 |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
152 |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
153 if (call_process_exited) |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
154 { |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
155 close (XFASTINT (Fcar (fdpid))); |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
156 return Qnil; |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
157 } |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
158 |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
159 if (EMACS_KILLPG (pid, SIGINT) == 0) |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
160 { |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
161 int count = specpdl_ptr - specpdl; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
162 record_unwind_protect (call_process_kill, fdpid); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
163 message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
164 immediate_quit = 1; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
165 QUIT; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
166 wait_for_termination (pid); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
167 immediate_quit = 0; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
168 specpdl_ptr = specpdl + count; /* Discard the unwind protect. */ |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
169 message1 ("Waiting for process to die...done"); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
170 } |
296 | 171 synch_process_alive = 0; |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
172 close (XFASTINT (Fcar (fdpid))); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
173 #endif /* not MSDOS */ |
296 | 174 return Qnil; |
175 } | |
176 | |
177 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0, | |
178 "Call PROGRAM synchronously in separate process.\n\ | |
179 The program's input comes from file INFILE (nil means `/dev/null').\n\ | |
180 Insert output in BUFFER before point; t means current buffer;\n\ | |
181 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
182 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
183 REAL-BUFFER says what to do with standard output, as above,\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
184 while STDERR-FILE says what to do with standard error in the child.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
185 STDERR-FILE may be nil (discard standard error output),\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
186 t (mix it with ordinary output), or a file name string.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
187 \n\ |
296 | 188 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ |
189 Remaining arguments are strings passed as command arguments to PROGRAM.\n\ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
190 \n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
191 If BUFFER is 0, `call-process' returns immediately with value nil.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
192 Otherwise it waits for PROGRAM to terminate\n\ |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
193 and returns a numeric exit status or a signal description string.\n\ |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
194 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
296 | 195 (nargs, args) |
196 int nargs; | |
197 register Lisp_Object *args; | |
198 { | |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
199 Lisp_Object infile, buffer, current_dir, display, path; |
296 | 200 int fd[2]; |
201 int filefd; | |
202 register int pid; | |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
203 char buf[16384]; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
204 char *bufptr = buf; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
205 int bufsize = 16384; |
296 | 206 int count = specpdl_ptr - specpdl; |
207 register unsigned char **new_argv | |
208 = (unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *)); | |
209 struct buffer *old = current_buffer; | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
210 /* File to use for stderr in the child. |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
211 t means use same as standard output. */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
212 Lisp_Object error_file; |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
213 #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
214 char *outf, *tempfile; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
215 int outfilefd; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
216 #endif |
296 | 217 #if 0 |
218 int mask; | |
219 #endif | |
220 CHECK_STRING (args[0], 0); | |
221 | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
222 error_file = Qt; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
223 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
224 #ifndef subprocesses |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
225 /* Without asynchronous processes we cannot have BUFFER == 0. */ |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
226 if (nargs >= 3 && INTEGERP (args[2])) |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
227 error ("Operating system cannot handle asynchronous subprocesses"); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
228 #endif /* subprocesses */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
229 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
230 if (nargs >= 2 && ! NILP (args[1])) |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
231 { |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
232 infile = Fexpand_file_name (args[1], current_buffer->directory); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
233 CHECK_STRING (infile, 1); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
234 } |
296 | 235 else |
2432
17a84e60603b
New macros NULL_DEVICE and EXEC_SUFFIXES, to give the name of the
Jim Blandy <jimb@redhat.com>
parents:
2286
diff
changeset
|
236 infile = build_string (NULL_DEVICE); |
648 | 237 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
238 if (nargs >= 3) |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
239 { |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
240 buffer = args[2]; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
241 |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
242 /* If BUFFER is a list, its meaning is |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
243 (BUFFER-FOR-STDOUT FILE-FOR-STDERR). */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
244 if (CONSP (buffer)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
245 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
246 if (CONSP (XCONS (buffer)->cdr)) |
11513
41e01a3ef4f0
(child_setup): Reword "can't exec" message.
Richard M. Stallman <rms@gnu.org>
parents:
11393
diff
changeset
|
247 error_file = Fexpand_file_name (XCONS (XCONS (buffer)->cdr)->car, |
41e01a3ef4f0
(child_setup): Reword "can't exec" message.
Richard M. Stallman <rms@gnu.org>
parents:
11393
diff
changeset
|
248 Qnil); |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
249 buffer = XCONS (buffer)->car; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
250 } |
296 | 251 |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
252 if (!(EQ (buffer, Qnil) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
253 || EQ (buffer, Qt) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
254 || XFASTINT (buffer) == 0)) |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
255 { |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
256 Lisp_Object spec_buffer; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
257 spec_buffer = buffer; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
258 buffer = Fget_buffer (buffer); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
259 /* Mention the buffer name for a better error message. */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
260 if (NILP (buffer)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
261 CHECK_BUFFER (spec_buffer, 2); |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
262 CHECK_BUFFER (buffer, 2); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
263 } |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
264 } |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
265 else |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
266 buffer = Qnil; |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
267 |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
268 /* Make sure that the child will be able to chdir to the current |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
269 buffer's current directory, or its unhandled equivalent. We |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
270 can't just have the child check for an error when it does the |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
271 chdir, since it's in a vfork. |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
272 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
273 We have to GCPRO around this because Fexpand_file_name, |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
274 Funhandled_file_name_directory, and Ffile_accessible_directory_p |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
275 might call a file name handling function. The argument list is |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
276 protected by the caller, so all we really have to worry about is |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
277 buffer. */ |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
278 { |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
279 struct gcpro gcpro1, gcpro2, gcpro3; |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
280 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
281 current_dir = current_buffer->directory; |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
282 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
283 GCPRO3 (infile, buffer, current_dir); |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
284 |
6391
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
285 current_dir |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
286 = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
287 Qnil); |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
288 if (NILP (Ffile_accessible_directory_p (current_dir))) |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
289 report_file_error ("Setting current directory", |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
290 Fcons (current_buffer->directory, Qnil)); |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
291 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
292 UNGCPRO; |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
293 } |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
294 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
295 display = nargs >= 4 ? args[3] : Qnil; |
296 | 296 |
6391
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
297 filefd = open (XSTRING (infile)->data, O_RDONLY, 0); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
298 if (filefd < 0) |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
299 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
300 report_file_error ("Opening process input file", Fcons (infile, Qnil)); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
301 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
302 /* Search for program; barf if not found. */ |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
303 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
304 struct gcpro gcpro1; |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
305 |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
306 GCPRO1 (current_dir); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
307 openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 1); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
308 UNGCPRO; |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
309 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
310 if (NILP (path)) |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
311 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
312 close (filefd); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
313 report_file_error ("Searching for program", Fcons (args[0], Qnil)); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
314 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
315 new_argv[0] = XSTRING (path)->data; |
296 | 316 { |
317 register int i; | |
318 for (i = 4; i < nargs; i++) | |
319 { | |
320 CHECK_STRING (args[i], i); | |
321 new_argv[i - 3] = XSTRING (args[i])->data; | |
322 } | |
323 new_argv[i - 3] = 0; | |
324 } | |
325 | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
326 #ifdef MSDOS /* MW, July 1993 */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
327 if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP"))) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
328 strcpy (tempfile = alloca (strlen (outf) + 20), outf); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
329 else |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
330 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
331 tempfile = alloca (20); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
332 *tempfile = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
333 } |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
334 dostounix_filename (tempfile); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
335 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
336 strcat (tempfile, "/"); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
337 strcat (tempfile, "detmp.XXX"); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
338 mktemp (tempfile); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
339 |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
340 outfilefd = creat (tempfile, S_IREAD | S_IWRITE); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
341 if (outfilefd < 0) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
342 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
343 close (filefd); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
344 report_file_error ("Opening process output file", Fcons (tempfile, Qnil)); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
345 } |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
346 fd[1] = outfilefd; |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
347 #endif |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
348 |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
349 if (INTEGERP (buffer)) |
2432
17a84e60603b
New macros NULL_DEVICE and EXEC_SUFFIXES, to give the name of the
Jim Blandy <jimb@redhat.com>
parents:
2286
diff
changeset
|
350 fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; |
296 | 351 else |
352 { | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
353 #ifndef MSDOS |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
354 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
355 pipe_with_inherited_out (fd); |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
356 #else /* not WINDOWSNT */ |
296 | 357 pipe (fd); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
358 #endif /* not WINDOWSNT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
359 #endif |
296 | 360 #if 0 |
361 /* Replaced by close_process_descs */ | |
362 set_exclusive_use (fd[0]); | |
363 #endif | |
364 } | |
365 | |
366 { | |
367 /* child_setup must clobber environ in systems with true vfork. | |
368 Protect it from permanent change. */ | |
369 register char **save_environ = environ; | |
370 register int fd1 = fd[1]; | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
371 int fd_error = fd1; |
296 | 372 |
373 #if 0 /* Some systems don't have sigblock. */ | |
638 | 374 mask = sigblock (sigmask (SIGCHLD)); |
296 | 375 #endif |
376 | |
377 /* Record that we're about to create a synchronous process. */ | |
378 synch_process_alive = 1; | |
379 | |
4977
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
380 /* These vars record information from process termination. |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
381 Clear them now before process can possibly terminate, |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
382 to avoid timing error if process terminates soon. */ |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
383 synch_process_death = 0; |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
384 synch_process_retcode = 0; |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
385 |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
386 if (NILP (error_file)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
387 fd_error = open (NULL_DEVICE, O_WRONLY); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
388 else if (STRINGP (error_file)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
389 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
390 #ifdef DOS_NT |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
391 fd_error = open (XSTRING (error_file)->data, |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
392 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
393 S_IREAD | S_IWRITE); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
394 #else /* not DOS_NT */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
395 fd_error = creat (XSTRING (error_file)->data, 0666); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
396 #endif /* not DOS_NT */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
397 } |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
398 |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
399 if (fd_error < 0) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
400 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
401 close (filefd); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
402 close (fd[0]); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
403 if (fd1 >= 0) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
404 close (fd1); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
405 report_file_error ("Cannot open", error_file); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
406 } |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
407 #ifdef MSDOS /* MW, July 1993 */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
408 /* ??? Someone who knows MSDOG needs to check whether this properly |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
409 closes all descriptors that it opens. |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
410 |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
411 Note that run_msdos_command() actually returns the child process |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
412 exit status, not its PID, so we assign it to `synch_process_retcode' |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
413 below. */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
414 pid = run_msdos_command (new_argv, current_dir, |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
415 filefd, outfilefd, fd_error); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
416 |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
417 /* Record that the synchronous process exited and note its |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
418 termination status. */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
419 synch_process_alive = 0; |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
420 synch_process_retcode = pid; |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
421 if (synch_process_retcode < 0) /* means it couldn't be exec'ed */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
422 synch_process_death = strerror(errno); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
423 |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
424 close (outfilefd); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
425 if (fd_error != outfilefd) |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
426 close (fd_error); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
427 fd1 = -1; /* No harm in closing that one! */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
428 fd[0] = open (tempfile, NILP (Vbinary_process_output) ? O_TEXT : O_BINARY); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
429 if (fd[0] < 0) |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
430 { |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
431 unlink (tempfile); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
432 close (filefd); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
433 report_file_error ("Cannot re-open temporary file", Qnil); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
434 } |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
435 #else /* not MSDOS */ |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
436 #ifdef WINDOWSNT |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
437 pid = child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
438 #else /* not WINDOWSNT */ |
296 | 439 pid = vfork (); |
440 | |
441 if (pid == 0) | |
442 { | |
443 if (fd[0] >= 0) | |
444 close (fd[0]); | |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3814
diff
changeset
|
445 #ifdef USG |
296 | 446 setpgrp (); |
447 #else | |
448 setpgrp (pid, pid); | |
449 #endif /* USG */ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
450 child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); |
296 | 451 } |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
452 #endif /* not WINDOWSNT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
453 #endif /* not MSDOS */ |
296 | 454 |
455 environ = save_environ; | |
456 | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
457 /* Close most of our fd's, but not fd[0] |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
458 since we will use that to read input from. */ |
296 | 459 close (filefd); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
460 if (fd1 >= 0) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
461 close (fd1); |
296 | 462 } |
463 | |
464 if (pid < 0) | |
465 { | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
466 if (fd[0] >= 0) |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
467 close (fd[0]); |
296 | 468 report_file_error ("Doing vfork", Qnil); |
469 } | |
470 | |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
471 if (INTEGERP (buffer)) |
296 | 472 { |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
473 if (fd[0] >= 0) |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
474 close (fd[0]); |
296 | 475 #ifndef subprocesses |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
476 /* If Emacs has been built with asynchronous subprocess support, |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
477 we don't need to do this, I think because it will then have |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
478 the facilities for handling SIGCHLD. */ |
296 | 479 wait_without_blocking (); |
480 #endif /* subprocesses */ | |
481 return Qnil; | |
482 } | |
483 | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
484 /* Enable sending signal if user quits below. */ |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
485 call_process_exited = 0; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
486 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
487 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
488 /* MSDOS needs different cleanup information. */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
489 record_unwind_protect (call_process_cleanup, |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
490 Fcons (make_number (fd[0]), build_string (tempfile))); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
491 #else |
296 | 492 record_unwind_protect (call_process_cleanup, |
493 Fcons (make_number (fd[0]), make_number (pid))); | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
494 #endif /* not MSDOS */ |
296 | 495 |
496 | |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
497 if (BUFFERP (buffer)) |
296 | 498 Fset_buffer (buffer); |
499 | |
500 immediate_quit = 1; | |
501 QUIT; | |
502 | |
503 { | |
504 register int nread; | |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
505 int first = 1; |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
506 int total_read = 0; |
296 | 507 |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
508 while (1) |
296 | 509 { |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
510 /* Repeatedly read until we've filled as much as possible |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
511 of the buffer size we have. But don't read |
14036 | 512 less than 1024--save that for the next bufferful. */ |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
513 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
514 nread = 0; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
515 while (nread < bufsize - 1024) |
8853
f44e40e722b2
(Fcall_process) [__osf__ && __alpha]:
Richard M. Stallman <rms@gnu.org>
parents:
8737
diff
changeset
|
516 { |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
517 int this_read |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
518 = read (fd[0], bufptr + nread, bufsize - nread); |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
519 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
520 if (this_read < 0) |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
521 goto give_up; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
522 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
523 if (this_read == 0) |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
524 goto give_up_1; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
525 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
526 nread += this_read; |
8853
f44e40e722b2
(Fcall_process) [__osf__ && __alpha]:
Richard M. Stallman <rms@gnu.org>
parents:
8737
diff
changeset
|
527 } |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
528 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
529 give_up_1: |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
530 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
531 /* Now NREAD is the total amount of data in the buffer. */ |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
532 if (nread == 0) |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
533 break; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
534 |
296 | 535 immediate_quit = 0; |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
536 total_read += nread; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
537 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
538 if (!NILP (buffer)) |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
539 insert (bufptr, nread); |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
540 |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
541 /* Make the buffer bigger as we continue to read more data, |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
542 but not past 64k. */ |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
543 if (bufsize < 64 * 1024 && total_read > 32 * bufsize) |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
544 { |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
545 bufsize *= 2; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
546 bufptr = (char *) alloca (bufsize); |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
547 } |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
548 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
549 if (!NILP (display) && INTERACTIVE) |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
550 { |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
551 if (first) |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
552 prepare_menu_bars (); |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
553 first = 0; |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
554 redisplay_preserve_echo_area (); |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
555 } |
296 | 556 immediate_quit = 1; |
557 QUIT; | |
558 } | |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
559 give_up: ; |
296 | 560 } |
561 | |
562 /* Wait for it to terminate, unless it already has. */ | |
563 wait_for_termination (pid); | |
564 | |
565 immediate_quit = 0; | |
566 | |
567 set_buffer_internal (old); | |
568 | |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
569 /* Don't kill any children that the subprocess may have left behind |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
570 when exiting. */ |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
571 call_process_exited = 1; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
572 |
296 | 573 unbind_to (count, Qnil); |
574 | |
575 if (synch_process_death) | |
576 return build_string (synch_process_death); | |
577 return make_number (synch_process_retcode); | |
578 } | |
579 #endif | |
580 | |
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
581 static Lisp_Object |
296 | 582 delete_temp_file (name) |
583 Lisp_Object name; | |
584 { | |
10083
2d7a561cc92c
(delete_temp_file): Use internal_delete_file.
Richard M. Stallman <rms@gnu.org>
parents:
9786
diff
changeset
|
585 /* Use Fdelete_file (indirectly) because that runs a file name handler. |
8737
72b312ebaa10
(delete_temp_file): Use Fdelete_file.
Richard M. Stallman <rms@gnu.org>
parents:
8555
diff
changeset
|
586 We did that when writing the file, so we should do so when deleting. */ |
10083
2d7a561cc92c
(delete_temp_file): Use internal_delete_file.
Richard M. Stallman <rms@gnu.org>
parents:
9786
diff
changeset
|
587 internal_delete_file (name); |
296 | 588 } |
589 | |
590 DEFUN ("call-process-region", Fcall_process_region, Scall_process_region, | |
591 3, MANY, 0, | |
592 "Send text from START to END to a synchronous process running PROGRAM.\n\ | |
593 Delete the text if fourth arg DELETE is non-nil.\n\ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
594 \n\ |
296 | 595 Insert output in BUFFER before point; t means current buffer;\n\ |
596 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
597 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
598 REAL-BUFFER says what to do with standard output, as above,\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
599 while STDERR-FILE says what to do with standard error in the child.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
600 STDERR-FILE may be nil (discard standard error output),\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
601 t (mix it with ordinary output), or a file name string.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
602 \n\ |
296 | 603 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ |
604 Remaining args are passed to PROGRAM at startup as command args.\n\ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
605 \n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
606 If BUFFER is nil, `call-process-region' returns immediately with value nil.\n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
607 Otherwise it waits for PROGRAM to terminate\n\ |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
608 and returns a numeric exit status or a signal description string.\n\ |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
609 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
296 | 610 (nargs, args) |
611 int nargs; | |
612 register Lisp_Object *args; | |
613 { | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
614 struct gcpro gcpro1; |
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
615 Lisp_Object filename_string; |
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
616 register Lisp_Object start, end; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
617 #ifdef DOS_NT |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
618 char *tempfile; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
619 #else |
296 | 620 char tempfile[20]; |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
621 #endif |
296 | 622 int count = specpdl_ptr - specpdl; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
623 #ifdef DOS_NT |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
624 char *outf = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
625 |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
626 if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP"))) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
627 strcpy (tempfile = alloca (strlen (outf) + 20), outf); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
628 else |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
629 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
630 tempfile = alloca (20); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
631 *tempfile = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
632 } |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
633 dostounix_filename (tempfile); |
12238
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
634 if (!IS_DIRECTORY_SEP (tempfile[strlen (tempfile) - 1])) |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
635 strcat (tempfile, "/"); |
12238
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
636 #ifdef WINDOWSNT |
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
637 strcat (tempfile, "emXXXXXX"); |
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
638 #else |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
639 strcat (tempfile, "detmp.XXX"); |
12238
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
640 #endif |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
641 #else /* not DOS_NT */ |
296 | 642 |
643 #ifdef VMS | |
644 strcpy (tempfile, "tmp:emacsXXXXXX."); | |
645 #else | |
646 strcpy (tempfile, "/tmp/emacsXXXXXX"); | |
647 #endif | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
648 #endif /* not DOS_NT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
649 |
296 | 650 mktemp (tempfile); |
651 | |
652 filename_string = build_string (tempfile); | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
653 GCPRO1 (filename_string); |
296 | 654 start = args[0]; |
655 end = args[1]; | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
656 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
657 specbind (Qbuffer_file_type, Vbinary_process_input); |
12854
b435aa964922
(Fcall_process_region): Pass new arg to Fwrite_region.
Richard M. Stallman <rms@gnu.org>
parents:
12615
diff
changeset
|
658 Fwrite_region (start, end, filename_string, Qnil, Qlambda, Qnil); |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
659 unbind_to (count, Qnil); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
660 #else /* not DOS_NT */ |
12854
b435aa964922
(Fcall_process_region): Pass new arg to Fwrite_region.
Richard M. Stallman <rms@gnu.org>
parents:
12615
diff
changeset
|
661 Fwrite_region (start, end, filename_string, Qnil, Qlambda, Qnil); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
662 #endif /* not DOS_NT */ |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
663 |
296 | 664 record_unwind_protect (delete_temp_file, filename_string); |
665 | |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
666 if (!NILP (args[3])) |
296 | 667 Fdelete_region (start, end); |
668 | |
669 args[3] = filename_string; | |
670 | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
671 RETURN_UNGCPRO (unbind_to (count, Fcall_process (nargs - 2, args + 2))); |
296 | 672 } |
673 | |
674 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
675 | |
676 /* This is the last thing run in a newly forked inferior | |
677 either synchronous or asynchronous. | |
678 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2. | |
679 Initialize inferior's priority, pgrp, connected dir and environment. | |
680 then exec another program based on new_argv. | |
681 | |
682 This function may change environ for the superior process. | |
683 Therefore, the superior process must save and restore the value | |
684 of environ around the vfork and the call to this function. | |
685 | |
686 ENV is the environment for the subprocess. | |
687 | |
688 SET_PGRP is nonzero if we should put the subprocess into a separate | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
689 process group. |
296 | 690 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
691 CURRENT_DIR is an elisp string giving the path of the current |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
692 directory the subprocess should have. Since we can't really signal |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
693 a decent error from within the child, this should be verified as an |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
694 executable directory by the parent. */ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
695 |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
696 child_setup (in, out, err, new_argv, set_pgrp, current_dir) |
296 | 697 int in, out, err; |
698 register char **new_argv; | |
699 int set_pgrp; | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
700 Lisp_Object current_dir; |
296 | 701 { |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
702 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
703 /* The MSDOS port of gcc cannot fork, vfork, ... so we must call system |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
704 instead. */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
705 #else /* not MSDOS */ |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
706 char **env; |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
707 char *pwd_var; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
708 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
709 int cpid; |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
710 HANDLE handles[4]; |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
711 #endif /* WINDOWSNT */ |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
712 |
5530
7ff479a8e8bf
(child_setup): Don't declare PID `register'; we later take its address.
Roland McGrath <roland@gnu.org>
parents:
5516
diff
changeset
|
713 int pid = getpid (); |
296 | 714 |
7481
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
715 #ifdef SET_EMACS_PRIORITY |
1201
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
716 { |
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
717 extern int emacs_priority; |
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
718 |
7481
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
719 if (emacs_priority < 0) |
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
720 nice (- emacs_priority); |
1201
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
721 } |
7161
67618cd7bdbf
(child_setup): Test PRIO_PROCESS, as in sys_subshell.
Richard M. Stallman <rms@gnu.org>
parents:
7000
diff
changeset
|
722 #endif |
296 | 723 |
724 #ifdef subprocesses | |
725 /* Close Emacs's descriptors that this process should not have. */ | |
726 close_process_descs (); | |
727 #endif | |
5569
b9e2884ca8e6
(child_setup): Call close_load_descs.
Richard M. Stallman <rms@gnu.org>
parents:
5530
diff
changeset
|
728 close_load_descs (); |
296 | 729 |
730 /* Note that use of alloca is always safe here. It's obvious for systems | |
731 that do not have true vfork or that have true (stack) alloca. | |
732 If using vfork and C_ALLOCA it is safe because that changes | |
733 the superior's static variables as if the superior had done alloca | |
734 and will be cleaned up in the usual way. */ | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
735 { |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
736 register char *temp; |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
737 register int i; |
296 | 738 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
739 i = XSTRING (current_dir)->size; |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
740 pwd_var = (char *) alloca (i + 6); |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
741 temp = pwd_var + 4; |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
742 bcopy ("PWD=", pwd_var, 4); |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
743 bcopy (XSTRING (current_dir)->data, temp, i); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
744 if (!IS_DIRECTORY_SEP (temp[i - 1])) temp[i++] = DIRECTORY_SEP; |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
745 temp[i] = 0; |
538 | 746 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
747 /* We can't signal an Elisp error here; we're in a vfork. Since |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
748 the callers check the current directory before forking, this |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
749 should only return an error if the directory's permissions |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
750 are changed between the check and this chdir, but we should |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
751 at least check. */ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
752 if (chdir (temp) < 0) |
9609
74985a8972e4
(child_setup): Always use _exit.
Richard M. Stallman <rms@gnu.org>
parents:
9138
diff
changeset
|
753 _exit (errno); |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
754 |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
755 /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
756 while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
757 temp[--i] = 0; |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
758 } |
296 | 759 |
760 /* Set `env' to a vector of the strings in Vprocess_environment. */ | |
761 { | |
762 register Lisp_Object tem; | |
763 register char **new_env; | |
764 register int new_length; | |
765 | |
766 new_length = 0; | |
767 for (tem = Vprocess_environment; | |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
768 CONSP (tem) && STRINGP (XCONS (tem)->car); |
296 | 769 tem = XCONS (tem)->cdr) |
770 new_length++; | |
771 | |
7722
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
772 /* new_length + 2 to include PWD and terminating 0. */ |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
773 env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
774 |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
775 /* If we have a PWD envvar, pass one down, |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
776 but with corrected value. */ |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
777 if (getenv ("PWD")) |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
778 *new_env++ = pwd_var; |
296 | 779 |
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
780 /* Copy the Vprocess_environment strings into new_env. */ |
296 | 781 for (tem = Vprocess_environment; |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
782 CONSP (tem) && STRINGP (XCONS (tem)->car); |
296 | 783 tem = XCONS (tem)->cdr) |
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
784 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
785 char **ep = env; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
786 char *string = (char *) XSTRING (XCONS (tem)->car)->data; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
787 /* See if this string duplicates any string already in the env. |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
788 If so, don't put it in. |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
789 When an env var has multiple definitions, |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
790 we keep the definition that comes first in process-environment. */ |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
791 for (; ep != new_env; ep++) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
792 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
793 char *p = *ep, *q = string; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
794 while (1) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
795 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
796 if (*q == 0) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
797 /* The string is malformed; might as well drop it. */ |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
798 goto duplicate; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
799 if (*q != *p) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
800 break; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
801 if (*q == '=') |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
802 goto duplicate; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
803 p++, q++; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
804 } |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
805 } |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
806 *new_env++ = string; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
807 duplicate: ; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
808 } |
296 | 809 *new_env = 0; |
810 } | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
811 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
812 prepare_standard_handles (in, out, err, handles); |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
813 #else /* not WINDOWSNT */ |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
814 /* Make sure that in, out, and err are not actually already in |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
815 descriptors zero, one, or two; this could happen if Emacs is |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
816 started with its standard in, out, or error closed, as might |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
817 happen under X. */ |
12430
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
818 { |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
819 int oin = in, oout = out; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
820 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
821 /* We have to avoid relocating the same descriptor twice! */ |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
822 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
823 in = relocate_fd (in, 3); |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
824 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
825 if (out == oin) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
826 out = in; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
827 else |
6614
e095c5efe2e0
(child_setup): Check out==err when relocating fds.
Karl Heuer <kwzh@gnu.org>
parents:
6495
diff
changeset
|
828 out = relocate_fd (out, 3); |
12430
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
829 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
830 if (err == oin) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
831 err = in; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
832 else if (err == oout) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
833 err = out; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
834 else |
6614
e095c5efe2e0
(child_setup): Check out==err when relocating fds.
Karl Heuer <kwzh@gnu.org>
parents:
6495
diff
changeset
|
835 err = relocate_fd (err, 3); |
12430
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
836 } |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
837 |
296 | 838 close (0); |
839 close (1); | |
840 close (2); | |
841 | |
842 dup2 (in, 0); | |
843 dup2 (out, 1); | |
844 dup2 (err, 2); | |
845 close (in); | |
846 close (out); | |
847 close (err); | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
848 #endif /* not WINDOWSNT */ |
296 | 849 |
5179
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
850 #ifdef USG |
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
851 #ifndef SETPGRP_RELEASES_CTTY |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
852 setpgrp (); /* No arguments but equivalent in this case */ |
5179
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
853 #endif |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
854 #else |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
855 setpgrp (pid, pid); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
856 #endif /* USG */ |
5348 | 857 /* setpgrp_of_tty is incorrect here; it uses input_fd. */ |
858 EMACS_SET_TTY_PGRP (0, &pid); | |
296 | 859 |
860 #ifdef vipc | |
861 something missing here; | |
862 #endif /* vipc */ | |
863 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
864 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
865 /* Spawn the child. (See ntproc.c:Spawnve). */ |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
866 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); |
11379
23f7aa711f96
(child_setup) [WINDOWSNT]: Removed syntax errors.
Karl Heuer <kwzh@gnu.org>
parents:
11235
diff
changeset
|
867 if (cpid == -1) |
23f7aa711f96
(child_setup) [WINDOWSNT]: Removed syntax errors.
Karl Heuer <kwzh@gnu.org>
parents:
11235
diff
changeset
|
868 /* An error occurred while trying to spawn the process. */ |
23f7aa711f96
(child_setup) [WINDOWSNT]: Removed syntax errors.
Karl Heuer <kwzh@gnu.org>
parents:
11235
diff
changeset
|
869 report_file_error ("Spawning child process", Qnil); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
870 reset_standard_handles (in, out, err, handles); |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
871 return cpid; |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
872 #else /* not WINDOWSNT */ |
296 | 873 /* execvp does not accept an environment arg so the only way |
874 to pass this environment is to set environ. Our caller | |
875 is responsible for restoring the ambient value of environ. */ | |
876 environ = env; | |
877 execvp (new_argv[0], new_argv); | |
878 | |
11513
41e01a3ef4f0
(child_setup): Reword "can't exec" message.
Richard M. Stallman <rms@gnu.org>
parents:
11393
diff
changeset
|
879 write (1, "Can't exec program: ", 26); |
296 | 880 write (1, new_argv[0], strlen (new_argv[0])); |
11513
41e01a3ef4f0
(child_setup): Reword "can't exec" message.
Richard M. Stallman <rms@gnu.org>
parents:
11393
diff
changeset
|
881 write (1, "\n", 1); |
296 | 882 _exit (1); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
883 #endif /* not WINDOWSNT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
884 #endif /* not MSDOS */ |
296 | 885 } |
886 | |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
887 /* Move the file descriptor FD so that its number is not less than MIN. |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
888 If the file descriptor is moved at all, the original is freed. */ |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
889 int |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
890 relocate_fd (fd, min) |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
891 int fd, min; |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
892 { |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
893 if (fd >= min) |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
894 return fd; |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
895 else |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
896 { |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
897 int new = dup (fd); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
898 if (new == -1) |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
899 { |
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
900 char *message1 = "Error while setting up child: "; |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
901 char *errmessage = strerror (errno); |
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
902 char *message2 = "\n"; |
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
903 write (2, message1, strlen (message1)); |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
904 write (2, errmessage, strlen (errmessage)); |
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
905 write (2, message2, strlen (message2)); |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
906 _exit (1); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
907 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
908 /* Note that we hold the original FD open while we recurse, |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
909 to guarantee we'll get a new FD if we need it. */ |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
910 new = relocate_fd (new, min); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
911 close (fd); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
912 return new; |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
913 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
914 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
915 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
916 static int |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
917 getenv_internal (var, varlen, value, valuelen) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
918 char *var; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
919 int varlen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
920 char **value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
921 int *valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
922 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
923 Lisp_Object scan; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
924 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
925 for (scan = Vprocess_environment; CONSP (scan); scan = XCONS (scan)->cdr) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
926 { |
6495
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
927 Lisp_Object entry; |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
928 |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
929 entry = XCONS (scan)->car; |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
930 if (STRINGP (entry) |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
931 && XSTRING (entry)->size > varlen |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
932 && XSTRING (entry)->data[varlen] == '=' |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
933 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
934 /* NT environment variables are case insensitive. */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
935 && ! strnicmp (XSTRING (entry)->data, var, varlen) |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
936 #else /* not WINDOWSNT */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
937 && ! bcmp (XSTRING (entry)->data, var, varlen) |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
938 #endif /* not WINDOWSNT */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
939 ) |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
940 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
941 *value = (char *) XSTRING (entry)->data + (varlen + 1); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
942 *valuelen = XSTRING (entry)->size - (varlen + 1); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
943 return 1; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
944 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
945 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
946 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
947 return 0; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
948 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
949 |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
950 DEFUN ("getenv", Fgetenv, Sgetenv, 1, 1, 0, |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
951 "Return the value of environment variable VAR, as a string.\n\ |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
952 VAR should be a string. Value is nil if VAR is undefined in the environment.\n\ |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
953 This function consults the variable ``process-environment'' for its value.") |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
954 (var) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
955 Lisp_Object var; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
956 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
957 char *value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
958 int valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
959 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
960 CHECK_STRING (var, 0); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
961 if (getenv_internal (XSTRING (var)->data, XSTRING (var)->size, |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
962 &value, &valuelen)) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
963 return make_string (value, valuelen); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
964 else |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
965 return Qnil; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
966 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
967 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
968 /* A version of getenv that consults process_environment, easily |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
969 callable from C. */ |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
970 char * |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
971 egetenv (var) |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
972 char *var; |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
973 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
974 char *value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
975 int valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
976 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
977 if (getenv_internal (var, strlen (var), &value, &valuelen)) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
978 return value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
979 else |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
980 return 0; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
981 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
982 |
296 | 983 #endif /* not VMS */ |
984 | |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
985 /* This is run before init_cmdargs. */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
986 |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
987 init_callproc_1 () |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
988 { |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
989 char *data_dir = egetenv ("EMACSDATA"); |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
990 char *doc_dir = egetenv ("EMACSDOC"); |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
991 |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
992 Vdata_directory |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
993 = Ffile_name_as_directory (build_string (data_dir ? data_dir |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
994 : PATH_DATA)); |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
995 Vdoc_directory |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
996 = Ffile_name_as_directory (build_string (doc_dir ? doc_dir |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
997 : PATH_DOC)); |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
998 |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
999 /* Check the EMACSPATH environment variable, defaulting to the |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1000 PATH_EXEC path from paths.h. */ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1001 Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC); |
296 | 1002 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); |
1003 Vexec_path = nconc2 (decode_env_path ("PATH", ""), Vexec_path); | |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1004 } |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1005 |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1006 /* This is run after init_cmdargs, when Vinstallation_directory is valid. */ |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1007 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1008 init_callproc () |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1009 { |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1010 char *data_dir = egetenv ("EMACSDATA"); |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1011 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1012 register char * sh; |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1013 Lisp_Object tempdir; |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1014 |
5618
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1015 if (initialized && !NILP (Vinstallation_directory)) |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1016 { |
5618
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1017 /* Add to the path the lib-src subdir of the installation dir. */ |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1018 Lisp_Object tem; |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1019 tem = Fexpand_file_name (build_string ("lib-src"), |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1020 Vinstallation_directory); |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1021 if (NILP (Fmember (tem, Vexec_path))) |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1022 { |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1023 #ifndef DOS_NT |
7824
de1dfb8aea82
(init_callproc) [MSDOS]: Exclude less code, so ../etc
Richard M. Stallman <rms@gnu.org>
parents:
7782
diff
changeset
|
1024 /* MSDOS uses wrapped binaries, so don't do this. */ |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1025 Vexec_path = nconc2 (Vexec_path, Fcons (tem, Qnil)); |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1026 Vexec_directory = Ffile_name_as_directory (tem); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1027 #endif /* not DOS_NT */ |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1028 } |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1029 |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1030 /* Maybe use ../etc as well as ../lib-src. */ |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1031 if (data_dir == 0) |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1032 { |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1033 tem = Fexpand_file_name (build_string ("etc"), |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1034 Vinstallation_directory); |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1035 Vdoc_directory = Ffile_name_as_directory (tem); |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1036 } |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1037 } |
7465
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1038 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1039 /* Look for the files that should be in etc. We don't use |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1040 Vinstallation_directory, because these files are never installed |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1041 near the executable, and they are never in the build |
7465
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1042 directory when that's different from the source directory. |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1043 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1044 Instead, if these files are not in the nominal place, we try the |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1045 source directory. */ |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1046 if (data_dir == 0) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1047 { |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1048 Lisp_Object tem, tem1, newdir; |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1049 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1050 tem = Fexpand_file_name (build_string ("GNU"), Vdata_directory); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1051 tem1 = Ffile_exists_p (tem); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1052 if (NILP (tem1)) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1053 { |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1054 newdir = Fexpand_file_name (build_string ("../etc/"), |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1055 build_string (PATH_DUMPLOADSEARCH)); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1056 tem = Fexpand_file_name (build_string ("GNU"), newdir); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1057 tem1 = Ffile_exists_p (tem); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1058 if (!NILP (tem1)) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1059 Vdata_directory = newdir; |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1060 } |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1061 } |
296 | 1062 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1063 tempdir = Fdirectory_file_name (Vexec_directory); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1064 if (access (XSTRING (tempdir)->data, 0) < 0) |
296 | 1065 { |
5688 | 1066 fprintf (stderr, |
1067 "Warning: arch-dependent data dir (%s) does not exist.\n", | |
1068 XSTRING (Vexec_directory)->data); | |
296 | 1069 sleep (2); |
1070 } | |
1071 | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1072 tempdir = Fdirectory_file_name (Vdata_directory); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1073 if (access (XSTRING (tempdir)->data, 0) < 0) |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1074 { |
5688 | 1075 fprintf (stderr, |
1076 "Warning: arch-independent data dir (%s) does not exist.\n", | |
1077 XSTRING (Vdata_directory)->data); | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1078 sleep (2); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1079 } |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1080 |
296 | 1081 #ifdef VMS |
1082 Vshell_file_name = build_string ("*dcl*"); | |
1083 #else | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1084 sh = (char *) getenv ("SHELL"); |
296 | 1085 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); |
1086 #endif | |
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1087 } |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1088 |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1089 set_process_environment () |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1090 { |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1091 register char **envp; |
296 | 1092 |
1093 Vprocess_environment = Qnil; | |
1094 #ifndef CANNOT_DUMP | |
1095 if (initialized) | |
1096 #endif | |
1097 for (envp = environ; *envp; envp++) | |
1098 Vprocess_environment = Fcons (build_string (*envp), | |
1099 Vprocess_environment); | |
1100 } | |
1101 | |
1102 syms_of_callproc () | |
1103 { | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1104 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1105 Qbuffer_file_type = intern ("buffer-file-type"); |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1106 staticpro (&Qbuffer_file_type); |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1107 |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1108 DEFVAR_LISP ("binary-process-input", &Vbinary_process_input, |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1109 "*If non-nil then new subprocesses are assumed to take binary input."); |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1110 Vbinary_process_input = Qnil; |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1111 |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1112 DEFVAR_LISP ("binary-process-output", &Vbinary_process_output, |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
1113 "*If non-nil then new subprocesses are assumed to produce binary output."); |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1114 Vbinary_process_output = Qnil; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1115 #endif /* DOS_NT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
1116 |
296 | 1117 DEFVAR_LISP ("shell-file-name", &Vshell_file_name, |
1118 "*File name to load inferior shells from.\n\ | |
1119 Initialized from the SHELL environment variable."); | |
1120 | |
1121 DEFVAR_LISP ("exec-path", &Vexec_path, | |
1122 "*List of directories to search programs to run in subprocesses.\n\ | |
1123 Each element is a string (directory name) or nil (try default directory)."); | |
1124 | |
1125 DEFVAR_LISP ("exec-directory", &Vexec_directory, | |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1126 "Directory of architecture-dependent files that come with GNU Emacs,\n\ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1127 especially executable programs intended for Emacs to invoke."); |
439 | 1128 |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1129 DEFVAR_LISP ("data-directory", &Vdata_directory, |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1130 "Directory of architecture-independent files that come with GNU Emacs,\n\ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1131 intended for Emacs to use."); |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1132 |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1133 DEFVAR_LISP ("doc-directory", &Vdoc_directory, |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1134 "Directory containing the DOC file that comes with GNU Emacs.\n\ |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1135 This is usually the same as data-directory."); |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1136 |
3064
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1137 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory, |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1138 "For internal use by the build procedure only.\n\ |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1139 This is the name of the directory in which the build procedure installed\n\ |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1140 Emacs's info files; the default value for Info-default-directory-list\n\ |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1141 includes this."); |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1142 Vconfigure_info_directory = build_string (PATH_INFO); |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1143 |
296 | 1144 DEFVAR_LISP ("process-environment", &Vprocess_environment, |
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1145 "List of environment variables for subprocesses to inherit.\n\ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1146 Each element should be a string of the form ENVVARNAME=VALUE.\n\ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1147 The environment which Emacs inherits is placed in this variable\n\ |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1148 when Emacs starts."); |
296 | 1149 |
1150 #ifndef VMS | |
1151 defsubr (&Scall_process); | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1504
diff
changeset
|
1152 defsubr (&Sgetenv); |
296 | 1153 #endif |
1154 defsubr (&Scall_process_region); | |
1155 } |