Mercurial > emacs
annotate src/callproc.c @ 18596:350a4dffed95
(lisp, shortlisp): Some files moved to subdirs.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 04 Jul 1997 05:05:10 +0000 |
parents | 8c13c54d52c8 |
children | 982814f78d0d |
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 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
296 | 20 |
21 | |
22 #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
|
23 #include <errno.h> |
296 | 24 |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
3932
diff
changeset
|
25 #include <config.h> |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7824
diff
changeset
|
26 #include <stdio.h> |
296 | 27 |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
28 extern int errno; |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
29 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
|
30 |
296 | 31 /* Define SIGCHLD as an alias for SIGCLD. */ |
32 | |
33 #if !defined (SIGCHLD) && defined (SIGCLD) | |
34 #define SIGCHLD SIGCLD | |
35 #endif /* SIGCLD */ | |
36 | |
37 #include <sys/types.h> | |
3932
9a411d86ca72
(PRIO_PROCESS): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
3826
diff
changeset
|
38 |
296 | 39 #include <sys/file.h> |
40 #ifdef USG5 | |
6818
6a9b0b5399ce
If we include fcntl.h, define INCLUDED_FCNTL.
Richard M. Stallman <rms@gnu.org>
parents:
6614
diff
changeset
|
41 #define INCLUDED_FCNTL |
296 | 42 #include <fcntl.h> |
43 #endif | |
44 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
45 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
46 #define NOMINMAX |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
47 #include <windows.h> |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
48 #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
|
49 #include <fcntl.h> |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16486
diff
changeset
|
50 #include "w32.h" |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
51 #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
|
52 #endif |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
53 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
54 #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
|
55 #include "msdos.h" |
6818
6a9b0b5399ce
If we include fcntl.h, define INCLUDED_FCNTL.
Richard M. Stallman <rms@gnu.org>
parents:
6614
diff
changeset
|
56 #define INCLUDED_FCNTL |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
57 #include <fcntl.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
58 #include <sys/stat.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
59 #include <sys/param.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
60 #include <errno.h> |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
61 #endif /* MSDOS */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
62 |
296 | 63 #ifndef O_RDONLY |
64 #define O_RDONLY 0 | |
65 #endif | |
66 | |
67 #ifndef O_WRONLY | |
68 #define O_WRONLY 1 | |
69 #endif | |
70 | |
71 #include "lisp.h" | |
72 #include "commands.h" | |
73 #include "buffer.h" | |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
74 #include "charset.h" |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
75 #include "coding.h" |
4701
05f6a91c2801
Include <paths.h>, not "paths.h".
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
76 #include <paths.h> |
296 | 77 #include "process.h" |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
78 #include "syssignal.h" |
5348 | 79 #include "systty.h" |
296 | 80 |
81 #ifdef VMS | |
82 extern noshare char **environ; | |
83 #else | |
84 extern char **environ; | |
85 #endif | |
86 | |
87 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
88 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
89 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
90 /* 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
|
91 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
|
92 \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
|
93 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
|
94 Lisp_Object Vbinary_process_input; |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
95 Lisp_Object Vbinary_process_output; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
96 #endif /* DOS_NT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
97 |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
98 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
|
99 Lisp_Object Vconfigure_info_directory; |
16627
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
100 Lisp_Object Vtemp_file_name_pattern; |
296 | 101 |
102 Lisp_Object Vshell_file_name; | |
103 | |
104 Lisp_Object Vprocess_environment; | |
105 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
106 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
107 Lisp_Object Qbuffer_file_type; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
108 #endif /* DOS_NT */ |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
109 |
296 | 110 /* True iff we are about to fork off a synchronous process or if we |
111 are waiting for it. */ | |
112 int synch_process_alive; | |
113 | |
114 /* Nonzero => this is a string explaining death of synchronous subprocess. */ | |
115 char *synch_process_death; | |
116 | |
117 /* If synch_process_death is zero, | |
118 this is exit code of synchronous subprocess. */ | |
119 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
|
120 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
121 extern Lisp_Object Vdoc_file_name; |
296 | 122 |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
123 /* 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
|
124 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
|
125 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
|
126 |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
127 /* 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
|
128 static int call_process_exited; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
129 |
296 | 130 #ifndef VMS /* VMS version is in vmsproc.c. */ |
131 | |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
132 static Lisp_Object |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
133 call_process_kill (fdpid) |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
134 Lisp_Object fdpid; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
135 { |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
136 close (XFASTINT (Fcar (fdpid))); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
137 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
|
138 synch_process_alive = 0; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
139 return Qnil; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
140 } |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
141 |
296 | 142 Lisp_Object |
143 call_process_cleanup (fdpid) | |
144 Lisp_Object fdpid; | |
145 { | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
146 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
147 /* 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
|
148 register Lisp_Object file; |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
149 file = Fcdr (fdpid); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
150 close (XFASTINT (Fcar (fdpid))); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
151 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
|
152 unlink (XSTRING (file)->data); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
153 #else /* not MSDOS */ |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
154 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
|
155 |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
156 |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
157 if (call_process_exited) |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
158 { |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
159 close (XFASTINT (Fcar (fdpid))); |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
160 return Qnil; |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
161 } |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
162 |
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
163 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
|
164 { |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 immediate_quit = 1; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
169 QUIT; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
170 wait_for_termination (pid); |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
171 immediate_quit = 0; |
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
172 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
|
173 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
|
174 } |
296 | 175 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
|
176 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
|
177 #endif /* not MSDOS */ |
296 | 178 return Qnil; |
179 } | |
180 | |
181 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0, | |
182 "Call PROGRAM synchronously in separate process.\n\ | |
183 The program's input comes from file INFILE (nil means `/dev/null').\n\ | |
184 Insert output in BUFFER before point; t means current buffer;\n\ | |
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 \n\ |
296 | 192 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ |
193 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
|
194 \n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
296 | 199 (nargs, args) |
200 int nargs; | |
201 register Lisp_Object *args; | |
202 { | |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
203 Lisp_Object infile, buffer, current_dir, display, path; |
296 | 204 int fd[2]; |
205 int filefd; | |
206 register int pid; | |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
207 char buf[16384]; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
208 char *bufptr = buf; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
209 int bufsize = 16384; |
296 | 210 int count = specpdl_ptr - specpdl; |
211 register unsigned char **new_argv | |
212 = (unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *)); | |
213 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
|
214 /* 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
|
215 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
|
216 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
|
217 #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
|
218 char *outf, *tempfile; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
219 int outfilefd; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
220 #endif |
296 | 221 #if 0 |
222 int mask; | |
223 #endif | |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
224 struct coding_system process_coding; /* coding-system of process output */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
225 struct coding_system argument_coding; /* coding-system of arguments */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
226 |
296 | 227 CHECK_STRING (args[0], 0); |
228 | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
229 error_file = Qt; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
230 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
231 #ifndef subprocesses |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
232 /* 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
|
233 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
|
234 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
|
235 #endif /* subprocesses */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
236 |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
237 /* Decide the coding-system for giving arguments and reading process |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
238 output. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
239 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
240 Lisp_Object val, *args2; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
241 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
242 Lisp_Object coding_systems = Qt; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
243 int i; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
244 |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
245 /* If arguments are supplied, we may have to encode them. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
246 if (nargs >= 5) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
247 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
248 if (NILP (val = Vcoding_system_for_write)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
249 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
250 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
251 args2[0] = Qcall_process; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
252 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
253 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
18182
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
254 if (CONSP (coding_systems)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
255 val = XCONS (coding_systems)->cdr; |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
256 else if (CONSP (Vdefault_process_coding_system)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
257 val = XCONS (Vdefault_process_coding_system)->cdr; |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
258 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
259 setup_coding_system (Fcheck_coding_system (val), &argument_coding); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
260 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
261 |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
262 /* If BUFFER is nil, we must read process output once and then |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
263 discard it, so setup coding system but with nil. If BUFFER is |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
264 an integer, we can discard it without reading. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
265 if (nargs < 3 || NILP (args[2])) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
266 setup_coding_system (Qnil, &process_coding); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
267 else if (!INTEGERP (args[2])) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
268 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
269 if (NILP (val = Vcoding_system_for_read)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
270 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
271 if (!EQ (coding_systems, Qt)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
272 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
273 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
274 args2[0] = Qcall_process; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
275 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
276 coding_systems |
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
277 = Ffind_operation_coding_system (nargs + 1, args2); |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
278 } |
18182
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
279 if (CONSP (coding_systems)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
280 val = XCONS (coding_systems)->car; |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
281 else if (CONSP (Vdefault_process_coding_system)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
282 val = XCONS (Vdefault_process_coding_system)->car; |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
283 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
284 setup_coding_system (Fcheck_coding_system (val), &process_coding); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
285 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
286 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
287 |
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
|
288 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
|
289 { |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
290 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
|
291 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
|
292 } |
296 | 293 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
|
294 infile = build_string (NULL_DEVICE); |
648 | 295 |
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
|
296 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
|
297 { |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
298 buffer = args[2]; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
299 |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
300 /* 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
|
301 (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
|
302 if (CONSP (buffer)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
303 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
304 if (CONSP (XCONS (buffer)->cdr)) |
15440
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
305 { |
15473
cdf40972804f
(Fcall_process): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
15440
diff
changeset
|
306 Lisp_Object stderr_file; |
15440
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
307 stderr_file = XCONS (XCONS (buffer)->cdr)->car; |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
308 |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
309 if (NILP (stderr_file) || EQ (Qt, stderr_file)) |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
310 error_file = stderr_file; |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
311 else |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
312 error_file = Fexpand_file_name (stderr_file, Qnil); |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
313 } |
87c6c9287f45
(Fcall_process): Handle t or nil as STDERR_FILE.
Richard M. Stallman <rms@gnu.org>
parents:
15236
diff
changeset
|
314 |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
315 buffer = XCONS (buffer)->car; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
316 } |
296 | 317 |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
318 if (!(EQ (buffer, Qnil) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
319 || EQ (buffer, Qt) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
320 || 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
|
321 { |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
322 Lisp_Object spec_buffer; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
323 spec_buffer = buffer; |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
324 buffer = Fget_buffer (buffer); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
325 /* 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
|
326 if (NILP (buffer)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
327 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
|
328 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
|
329 } |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
330 } |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
331 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
|
332 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
|
333 |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
334 /* 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
|
335 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
|
336 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
|
337 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
|
338 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 buffer. */ |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
344 { |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
345 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
|
346 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
347 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
|
348 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
349 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
|
350 |
6391
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
351 current_dir |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
352 = 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
|
353 Qnil); |
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
358 UNGCPRO; |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
359 } |
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
360 |
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
|
361 display = nargs >= 4 ? args[3] : Qnil; |
296 | 362 |
6391
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
363 filefd = open (XSTRING (infile)->data, O_RDONLY, 0); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
364 if (filefd < 0) |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
365 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
366 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
|
367 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
368 /* Search for program; barf if not found. */ |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
369 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
370 struct gcpro gcpro1; |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
371 |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
372 GCPRO1 (current_dir); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
373 openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 1); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
374 UNGCPRO; |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
375 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
376 if (NILP (path)) |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
377 { |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
378 close (filefd); |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
379 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
|
380 } |
d4fe8a853557
(Fcall_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6275
diff
changeset
|
381 new_argv[0] = XSTRING (path)->data; |
296 | 382 { |
383 register int i; | |
384 for (i = 4; i < nargs; i++) | |
385 { | |
386 CHECK_STRING (args[i], i); | |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
387 if (argument_coding.type == coding_type_no_conversion) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
388 new_argv[i - 3] = XSTRING (args[i])->data; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
389 else |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
390 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
391 /* We must encode the arguments. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
392 int size = encoding_buffer_size (&argument_coding, |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
393 XSTRING (args[i])->size); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
394 int produced, dummy; |
18494
c64480c04c07
(Fcall_process): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18489
diff
changeset
|
395 unsigned char *dummy1 = (unsigned char *) alloca (size); |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
396 |
18489
42257ed9c7e3
(Fcall_process): Avoid storing alloca result
Richard M. Stallman <rms@gnu.org>
parents:
18235
diff
changeset
|
397 /* The Irix 4.0 compiler barfs if we eliminate dummy. */ |
18494
c64480c04c07
(Fcall_process): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18489
diff
changeset
|
398 new_argv[i - 3] = dummy1; |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
399 produced = encode_coding (&argument_coding, |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
400 XSTRING (args[i])->data, new_argv[i - 3], |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
401 XSTRING (args[i])->size, size, &dummy); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
402 new_argv[i - 3][produced] = 0; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
403 } |
296 | 404 } |
405 new_argv[i - 3] = 0; | |
406 } | |
407 | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
408 #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
|
409 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
|
410 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
|
411 else |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
412 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
413 tempfile = alloca (20); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
414 *tempfile = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
415 } |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
416 dostounix_filename (tempfile); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
417 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
|
418 strcat (tempfile, "/"); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
419 strcat (tempfile, "detmp.XXX"); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
420 mktemp (tempfile); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
421 |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
422 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
|
423 if (outfilefd < 0) |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
424 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
425 close (filefd); |
15610 | 426 report_file_error ("Opening process output file", |
427 Fcons (build_string (tempfile), Qnil)); | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
428 } |
15610 | 429 fd[0] = filefd; |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
430 fd[1] = outfilefd; |
15610 | 431 #endif /* MSDOS */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
432 |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
433 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
|
434 fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; |
296 | 435 else |
436 { | |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
437 #ifndef MSDOS |
296 | 438 pipe (fd); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
439 #endif |
296 | 440 #if 0 |
441 /* Replaced by close_process_descs */ | |
442 set_exclusive_use (fd[0]); | |
443 #endif | |
444 } | |
445 | |
446 { | |
447 /* child_setup must clobber environ in systems with true vfork. | |
448 Protect it from permanent change. */ | |
449 register char **save_environ = environ; | |
450 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
|
451 int fd_error = fd1; |
296 | 452 |
453 #if 0 /* Some systems don't have sigblock. */ | |
638 | 454 mask = sigblock (sigmask (SIGCHLD)); |
296 | 455 #endif |
456 | |
457 /* Record that we're about to create a synchronous process. */ | |
458 synch_process_alive = 1; | |
459 | |
4977
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
460 /* 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
|
461 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
|
462 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
|
463 synch_process_death = 0; |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
464 synch_process_retcode = 0; |
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
465 |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
466 if (NILP (error_file)) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
467 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
|
468 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
|
469 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
470 #ifdef DOS_NT |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
471 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
|
472 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
|
473 S_IREAD | S_IWRITE); |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
474 #else /* not DOS_NT */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
475 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
|
476 #endif /* not DOS_NT */ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
477 } |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
478 |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
479 if (fd_error < 0) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
480 { |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
481 close (filefd); |
15610 | 482 if (fd[0] != filefd) |
483 close (fd[0]); | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
484 if (fd1 >= 0) |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
485 close (fd1); |
15610 | 486 #ifdef MSDOS |
487 unlink (tempfile); | |
488 #endif | |
489 report_file_error ("Cannot redirect stderr", | |
490 Fcons ((NILP (error_file) | |
491 ? build_string (NULL_DEVICE) : error_file), | |
492 Qnil)); | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
493 } |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
494 #ifdef MSDOS /* MW, July 1993 */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
495 /* ??? 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
|
496 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
|
497 |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
498 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
|
499 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
|
500 below. */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
501 pid = run_msdos_command (new_argv, current_dir, |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
502 filefd, outfilefd, fd_error); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
503 |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
504 /* 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
|
505 termination status. */ |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
506 synch_process_alive = 0; |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
507 synch_process_retcode = pid; |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
508 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
|
509 synch_process_death = strerror(errno); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
510 |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
511 close (outfilefd); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
512 if (fd_error != outfilefd) |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
513 close (fd_error); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
514 fd1 = -1; /* No harm in closing that one! */ |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
515 /* Since CRLF is converted to LF within `decode_coding', we can |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
516 always open a file with binary mode. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
517 fd[0] = open (tempfile, O_BINARY); |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
518 if (fd[0] < 0) |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
519 { |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
520 unlink (tempfile); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
521 close (filefd); |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
522 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
|
523 } |
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
524 #else /* not MSDOS */ |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
525 #ifdef WINDOWSNT |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
526 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
|
527 #else /* not WINDOWSNT */ |
296 | 528 pid = vfork (); |
529 | |
530 if (pid == 0) | |
531 { | |
532 if (fd[0] >= 0) | |
533 close (fd[0]); | |
18235
43ce16d5f31e
(Fcall_process): Use setsid to disconnect child
Richard M. Stallman <rms@gnu.org>
parents:
18182
diff
changeset
|
534 #ifdef HAVE_SETSID |
43ce16d5f31e
(Fcall_process): Use setsid to disconnect child
Richard M. Stallman <rms@gnu.org>
parents:
18182
diff
changeset
|
535 setsid (); |
43ce16d5f31e
(Fcall_process): Use setsid to disconnect child
Richard M. Stallman <rms@gnu.org>
parents:
18182
diff
changeset
|
536 #endif |
43ce16d5f31e
(Fcall_process): Use setsid to disconnect child
Richard M. Stallman <rms@gnu.org>
parents:
18182
diff
changeset
|
537 #if defined (USG) && !defined (BSD_PGRPS) |
296 | 538 setpgrp (); |
539 #else | |
540 setpgrp (pid, pid); | |
541 #endif /* USG */ | |
10839
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
542 child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); |
296 | 543 } |
13719
660032b84b23
(Fcall_process) [MSDOS]: Support redirection of
Karl Heuer <kwzh@gnu.org>
parents:
12854
diff
changeset
|
544 #endif /* not WINDOWSNT */ |
15225
a78a1df9690c
(Fcall_process): Fix previous change (now !MSDOS only).
Richard M. Stallman <rms@gnu.org>
parents:
15210
diff
changeset
|
545 |
a78a1df9690c
(Fcall_process): Fix previous change (now !MSDOS only).
Richard M. Stallman <rms@gnu.org>
parents:
15210
diff
changeset
|
546 /* The MSDOS case did this already. */ |
a78a1df9690c
(Fcall_process): Fix previous change (now !MSDOS only).
Richard M. Stallman <rms@gnu.org>
parents:
15210
diff
changeset
|
547 if (fd_error >= 0) |
a78a1df9690c
(Fcall_process): Fix previous change (now !MSDOS only).
Richard M. Stallman <rms@gnu.org>
parents:
15210
diff
changeset
|
548 close (fd_error); |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
549 #endif /* not MSDOS */ |
296 | 550 |
551 environ = save_environ; | |
552 | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
553 /* 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
|
554 since we will use that to read input from. */ |
296 | 555 close (filefd); |
15236
99d01b1b8799
(Fcall_process): Don't close the same fd twice.
Karl Heuer <kwzh@gnu.org>
parents:
15225
diff
changeset
|
556 if (fd1 >= 0 && fd1 != fd_error) |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
557 close (fd1); |
296 | 558 } |
559 | |
560 if (pid < 0) | |
561 { | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
562 if (fd[0] >= 0) |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
563 close (fd[0]); |
296 | 564 report_file_error ("Doing vfork", Qnil); |
565 } | |
566 | |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
567 if (INTEGERP (buffer)) |
296 | 568 { |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
569 if (fd[0] >= 0) |
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
570 close (fd[0]); |
296 | 571 #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
|
572 /* 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
|
573 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
|
574 the facilities for handling SIGCHLD. */ |
296 | 575 wait_without_blocking (); |
576 #endif /* subprocesses */ | |
577 return Qnil; | |
578 } | |
579 | |
6466
4b3c537e1169
(Fcall_process): Make sure to close descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
6391
diff
changeset
|
580 /* 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
|
581 call_process_exited = 0; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
582 |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
583 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
584 /* 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
|
585 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
|
586 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
|
587 #else |
296 | 588 record_unwind_protect (call_process_cleanup, |
589 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
|
590 #endif /* not MSDOS */ |
296 | 591 |
592 | |
9138
6c814eb4d892
(Fcall_process, child_setup, getenv_internal): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8853
diff
changeset
|
593 if (BUFFERP (buffer)) |
296 | 594 Fset_buffer (buffer); |
595 | |
596 immediate_quit = 1; | |
597 QUIT; | |
598 | |
599 { | |
600 register int nread; | |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
601 int first = 1; |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
602 int total_read = 0; |
296 | 603 |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
604 while (1) |
296 | 605 { |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
606 /* 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
|
607 of the buffer size we have. But don't read |
14036 | 608 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
|
609 |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
610 nread = process_coding.carryover_size; /* This value is initially 0. */ |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
611 while (nread < bufsize - 1024) |
8853
f44e40e722b2
(Fcall_process) [__osf__ && __alpha]:
Richard M. Stallman <rms@gnu.org>
parents:
8737
diff
changeset
|
612 { |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
613 int this_read |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
614 = 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
|
615 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
616 if (this_read < 0) |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
617 goto give_up; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
618 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
619 if (this_read == 0) |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
620 goto give_up_1; |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
621 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
622 nread += this_read; |
8853
f44e40e722b2
(Fcall_process) [__osf__ && __alpha]:
Richard M. Stallman <rms@gnu.org>
parents:
8737
diff
changeset
|
623 } |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
624 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
625 give_up_1: |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
626 |
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
627 /* 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
|
628 if (nread == 0) |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
629 /* Here, just tell decode_coding that we are processing the |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
630 last block. We break the loop after decoding. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
631 process_coding.last_block = 1; |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
632 |
296 | 633 immediate_quit = 0; |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
634 total_read += nread; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
635 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
636 if (!NILP (buffer)) |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
637 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
638 if (process_coding.type == coding_type_no_conversion) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
639 insert (bufptr, nread); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
640 else |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
641 { /* We have to decode the input. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
642 int size = decoding_buffer_size (&process_coding, bufsize); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
643 char *decoding_buf = get_conversion_buffer (size); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
644 int dummy; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
645 |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
646 nread = decode_coding (&process_coding, bufptr, decoding_buf, |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
647 nread, size, &dummy); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
648 if (nread > 0) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
649 insert (decoding_buf, nread); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
650 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
651 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
652 |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
653 if (process_coding.last_block) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
654 break; |
11619
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
655 |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
656 /* 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
|
657 but not past 64k. */ |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
658 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
|
659 { |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
660 bufsize *= 2; |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
661 bufptr = (char *) alloca (bufsize); |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
662 } |
ff4be652af46
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
11513
diff
changeset
|
663 |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
664 if (!NILP (buffer) && process_coding.carryover_size > 0) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
665 /* We have carryover in the last decoding. It should be |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
666 processed again after reading more data. */ |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
667 bcopy (process_coding.carryover, bufptr, |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
668 process_coding.carryover_size); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
669 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
670 if (!NILP (display) && INTERACTIVE) |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
671 { |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
672 if (first) |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
673 prepare_menu_bars (); |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
674 first = 0; |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
675 redisplay_preserve_echo_area (); |
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
676 } |
296 | 677 immediate_quit = 1; |
678 QUIT; | |
679 } | |
11780
6ae23eecab6a
(Fcall_process): Keep reading till buffer is nearly full.
Richard M. Stallman <rms@gnu.org>
parents:
11619
diff
changeset
|
680 give_up: ; |
296 | 681 } |
682 | |
683 /* Wait for it to terminate, unless it already has. */ | |
684 wait_for_termination (pid); | |
685 | |
686 immediate_quit = 0; | |
687 | |
688 set_buffer_internal (old); | |
689 | |
6275
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
690 /* 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
|
691 when exiting. */ |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
692 call_process_exited = 1; |
132464faeaf4
Don't kill remaining processes if child exits.
Richard M. Stallman <rms@gnu.org>
parents:
6031
diff
changeset
|
693 |
296 | 694 unbind_to (count, Qnil); |
695 | |
696 if (synch_process_death) | |
697 return build_string (synch_process_death); | |
698 return make_number (synch_process_retcode); | |
699 } | |
700 #endif | |
701 | |
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
702 static Lisp_Object |
296 | 703 delete_temp_file (name) |
704 Lisp_Object name; | |
705 { | |
10083
2d7a561cc92c
(delete_temp_file): Use internal_delete_file.
Richard M. Stallman <rms@gnu.org>
parents:
9786
diff
changeset
|
706 /* 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
|
707 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
|
708 internal_delete_file (name); |
296 | 709 } |
710 | |
711 DEFUN ("call-process-region", Fcall_process_region, Scall_process_region, | |
712 3, MANY, 0, | |
713 "Send text from START to END to a synchronous process running PROGRAM.\n\ | |
714 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
|
715 \n\ |
296 | 716 Insert output in BUFFER before point; t means current buffer;\n\ |
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 \n\ |
296 | 724 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ |
725 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
|
726 \n\ |
2e3eae2280eb
(Fcall_process): Extend BUFFER arg so it can specify
Richard M. Stallman <rms@gnu.org>
parents:
10083
diff
changeset
|
727 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
|
728 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
|
729 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
|
730 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
296 | 731 (nargs, args) |
732 int nargs; | |
733 register Lisp_Object *args; | |
734 { | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
735 struct gcpro gcpro1; |
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
736 Lisp_Object filename_string; |
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
737 register Lisp_Object start, end; |
16659
e7bf457086fb
(Fcall_process_region): Define missing local `count'.
Richard M. Stallman <rms@gnu.org>
parents:
16627
diff
changeset
|
738 int count = specpdl_ptr - specpdl; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
739 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
740 Lisp_Object coding_systems = Qt; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
741 Lisp_Object val, *args2; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
742 int i; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
743 #ifdef DOS_NT |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
744 char *tempfile; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
745 char *outf = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
746 |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
747 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
|
748 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
|
749 else |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
750 { |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
751 tempfile = alloca (20); |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
752 *tempfile = '\0'; |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
753 } |
12238
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
754 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
|
755 strcat (tempfile, "/"); |
15824
11517dc55f5b
(Fcall_process_region) [DOS_NT]: Avoid downcasing
Richard M. Stallman <rms@gnu.org>
parents:
15610
diff
changeset
|
756 if ('/' == DIRECTORY_SEP) |
11517dc55f5b
(Fcall_process_region) [DOS_NT]: Avoid downcasing
Richard M. Stallman <rms@gnu.org>
parents:
15610
diff
changeset
|
757 dostounix_filename (tempfile); |
11517dc55f5b
(Fcall_process_region) [DOS_NT]: Avoid downcasing
Richard M. Stallman <rms@gnu.org>
parents:
15610
diff
changeset
|
758 else |
11517dc55f5b
(Fcall_process_region) [DOS_NT]: Avoid downcasing
Richard M. Stallman <rms@gnu.org>
parents:
15610
diff
changeset
|
759 unixtodos_filename (tempfile); |
12238
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
760 #ifdef WINDOWSNT |
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
761 strcat (tempfile, "emXXXXXX"); |
f442c22815b8
(call-process-region) [DOS_NT]: Use IS_DIRECTORY_SEP.
Richard M. Stallman <rms@gnu.org>
parents:
11780
diff
changeset
|
762 #else |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
763 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
|
764 #endif |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
765 #else /* not DOS_NT */ |
16627
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
766 char *tempfile = (char *) alloca (XSTRING (Vtemp_file_name_pattern)->size + 1); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
767 bcopy (XSTRING (Vtemp_file_name_pattern)->data, tempfile, |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
768 XSTRING (Vtemp_file_name_pattern)->size + 1); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
769 #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
|
770 |
296 | 771 mktemp (tempfile); |
772 | |
773 filename_string = build_string (tempfile); | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
774 GCPRO1 (filename_string); |
296 | 775 start = args[0]; |
776 end = args[1]; | |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
777 /* Decide coding-system of the contents of the temporary file. */ |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
778 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
779 specbind (Qbuffer_file_type, Vbinary_process_input); |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
780 if (NILP (Vbinary_process_input)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
781 val = Qnil; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
782 else |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
783 #endif |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
784 if (NILP (val = Vcoding_system_for_write)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
785 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
786 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
787 args2[0] = Qcall_process_region; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
788 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
789 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
18182
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
790 if (CONSP (coding_systems)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
791 val = XCONS (coding_systems)->cdr; |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
792 else if (CONSP (Vdefault_process_coding_system)) |
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
793 val = XCONS (Vdefault_process_coding_system)->car; |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
794 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
795 specbind (intern ("coding-system-for-write"), val); |
18182
967f92654591
(Fcall_process): Pay attention to
Kenichi Handa <handa@m17n.org>
parents:
17729
diff
changeset
|
796 Fwrite_region (start, end, filename_string, Qnil, Qlambda, Qnil); |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
797 |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
798 #ifdef DOS_NT |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
799 if (NILP (Vbinary_process_input)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
800 val = Qnil; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
801 else |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
802 #endif |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
803 if (NILP (val = Vcoding_system_for_read)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
804 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
805 if (EQ (coding_systems, Qt)) |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
806 { |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
807 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
808 args2[0] = Qcall_process_region; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
809 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
18539
8c13c54d52c8
Call Ffind_operation_coding_system.
Kenichi Handa <handa@m17n.org>
parents:
18494
diff
changeset
|
810 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
17025
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
811 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
812 val = CONSP (coding_systems) ? XCONS (coding_systems)->car : Qnil; |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
813 } |
3c222a7edda1
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16659
diff
changeset
|
814 specbind (intern ("coding-system-for-read"), val); |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
815 |
296 | 816 record_unwind_protect (delete_temp_file, filename_string); |
817 | |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
818 if (!NILP (args[3])) |
296 | 819 Fdelete_region (start, end); |
820 | |
821 args[3] = filename_string; | |
822 | |
8555
f1b1537ed3f6
(Fcall_process_region): gcpro filename_string.
Karl Heuer <kwzh@gnu.org>
parents:
7900
diff
changeset
|
823 RETURN_UNGCPRO (unbind_to (count, Fcall_process (nargs - 2, args + 2))); |
296 | 824 } |
825 | |
826 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
827 | |
828 /* This is the last thing run in a newly forked inferior | |
829 either synchronous or asynchronous. | |
830 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2. | |
831 Initialize inferior's priority, pgrp, connected dir and environment. | |
832 then exec another program based on new_argv. | |
833 | |
834 This function may change environ for the superior process. | |
835 Therefore, the superior process must save and restore the value | |
836 of environ around the vfork and the call to this function. | |
837 | |
838 ENV is the environment for the subprocess. | |
839 | |
840 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
|
841 process group. |
296 | 842 |
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
|
843 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
|
844 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
|
845 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
|
846 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
|
847 |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
848 child_setup (in, out, err, new_argv, set_pgrp, current_dir) |
296 | 849 int in, out, err; |
850 register char **new_argv; | |
851 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
|
852 Lisp_Object current_dir; |
296 | 853 { |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
854 #ifdef MSDOS |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
855 /* 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
|
856 instead. */ |
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
857 #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
|
858 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
|
859 char *pwd_var; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
860 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
861 int cpid; |
15087
46157341f721
(Fcall_process) [WINDOWSNT]: Remove conditional NT code.
Richard M. Stallman <rms@gnu.org>
parents:
14872
diff
changeset
|
862 HANDLE handles[3]; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
863 #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
|
864 |
5530
7ff479a8e8bf
(child_setup): Don't declare PID `register'; we later take its address.
Roland McGrath <roland@gnu.org>
parents:
5516
diff
changeset
|
865 int pid = getpid (); |
296 | 866 |
7481
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
867 #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
|
868 { |
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
869 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
|
870 |
7481
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
871 if (emacs_priority < 0) |
b7d23c08750c
(child_setup): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7465
diff
changeset
|
872 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
|
873 } |
7161
67618cd7bdbf
(child_setup): Test PRIO_PROCESS, as in sys_subshell.
Richard M. Stallman <rms@gnu.org>
parents:
7000
diff
changeset
|
874 #endif |
296 | 875 |
876 #ifdef subprocesses | |
877 /* Close Emacs's descriptors that this process should not have. */ | |
878 close_process_descs (); | |
879 #endif | |
5569
b9e2884ca8e6
(child_setup): Call close_load_descs.
Richard M. Stallman <rms@gnu.org>
parents:
5530
diff
changeset
|
880 close_load_descs (); |
296 | 881 |
882 /* Note that use of alloca is always safe here. It's obvious for systems | |
883 that do not have true vfork or that have true (stack) alloca. | |
884 If using vfork and C_ALLOCA it is safe because that changes | |
885 the superior's static variables as if the superior had done alloca | |
886 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
|
887 { |
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
|
888 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
|
889 register int i; |
296 | 890 |
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
|
891 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
|
892 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
|
893 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
|
894 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
|
895 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
|
896 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
|
897 temp[i] = 0; |
538 | 898 |
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
|
899 /* 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 if (chdir (temp) < 0) |
9609
74985a8972e4
(child_setup): Always use _exit.
Richard M. Stallman <rms@gnu.org>
parents:
9138
diff
changeset
|
905 _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
|
906 |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
907 /* 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
|
908 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
|
909 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
|
910 } |
296 | 911 |
912 /* Set `env' to a vector of the strings in Vprocess_environment. */ | |
913 { | |
914 register Lisp_Object tem; | |
915 register char **new_env; | |
916 register int new_length; | |
917 | |
918 new_length = 0; | |
919 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
|
920 CONSP (tem) && STRINGP (XCONS (tem)->car); |
296 | 921 tem = XCONS (tem)->cdr) |
922 new_length++; | |
923 | |
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
|
924 /* 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
|
925 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
|
926 |
e422f06592d3
(child_setup): If PWD is set, set it in the child so that
Richard M. Stallman <rms@gnu.org>
parents:
7481
diff
changeset
|
927 /* 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
|
928 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
|
929 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
|
930 *new_env++ = pwd_var; |
296 | 931 |
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
932 /* Copy the Vprocess_environment strings into new_env. */ |
296 | 933 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
|
934 CONSP (tem) && STRINGP (XCONS (tem)->car); |
296 | 935 tem = XCONS (tem)->cdr) |
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
936 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
937 char **ep = env; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
938 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
|
939 /* 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
|
940 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
|
941 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
|
942 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
|
943 for (; ep != new_env; ep++) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
944 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
945 char *p = *ep, *q = string; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
946 while (1) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
947 { |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
948 if (*q == 0) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
949 /* 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
|
950 goto duplicate; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
951 if (*q != *p) |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
952 break; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
953 if (*q == '=') |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
954 goto duplicate; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
955 p++, q++; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
956 } |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
957 } |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
958 *new_env++ = string; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
959 duplicate: ; |
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
960 } |
296 | 961 *new_env = 0; |
962 } | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
963 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
964 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
|
965 #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
|
966 /* 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
|
967 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
|
968 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
|
969 happen under X. */ |
12430
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
970 { |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
971 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
|
972 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
973 /* 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
|
974 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
975 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
|
976 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
977 if (out == oin) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
978 out = in; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
979 else |
6614
e095c5efe2e0
(child_setup): Check out==err when relocating fds.
Karl Heuer <kwzh@gnu.org>
parents:
6495
diff
changeset
|
980 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
|
981 |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
982 if (err == oin) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
983 err = in; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
984 else if (err == oout) |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
985 err = out; |
14792ea851f9
(child_setup): Don't get confused if in == err.
Richard M. Stallman <rms@gnu.org>
parents:
12238
diff
changeset
|
986 else |
6614
e095c5efe2e0
(child_setup): Check out==err when relocating fds.
Karl Heuer <kwzh@gnu.org>
parents:
6495
diff
changeset
|
987 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
|
988 } |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
989 |
296 | 990 close (0); |
991 close (1); | |
992 close (2); | |
993 | |
994 dup2 (in, 0); | |
995 dup2 (out, 1); | |
996 dup2 (err, 2); | |
997 close (in); | |
998 close (out); | |
999 close (err); | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1000 #endif /* not WINDOWSNT */ |
296 | 1001 |
14872
c001b28bf068
(Fcall_process, child_setup): If BSD_PGRPS, call
Richard M. Stallman <rms@gnu.org>
parents:
14438
diff
changeset
|
1002 #if defined(USG) && !defined(BSD_PGRPS) |
5179
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
1003 #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
|
1004 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
|
1005 #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
|
1006 #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
|
1007 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
|
1008 #endif /* USG */ |
5348 | 1009 /* setpgrp_of_tty is incorrect here; it uses input_fd. */ |
1010 EMACS_SET_TTY_PGRP (0, &pid); | |
296 | 1011 |
1012 #ifdef vipc | |
1013 something missing here; | |
1014 #endif /* vipc */ | |
1015 | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1016 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1017 /* 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
|
1018 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
|
1019 if (cpid == -1) |
23f7aa711f96
(child_setup) [WINDOWSNT]: Removed syntax errors.
Karl Heuer <kwzh@gnu.org>
parents:
11235
diff
changeset
|
1020 /* 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
|
1021 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
|
1022 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
|
1023 return cpid; |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1024 #else /* not WINDOWSNT */ |
296 | 1025 /* execvp does not accept an environment arg so the only way |
1026 to pass this environment is to set environ. Our caller | |
1027 is responsible for restoring the ambient value of environ. */ | |
1028 environ = env; | |
1029 execvp (new_argv[0], new_argv); | |
1030 | |
14438
85fcb510947a
(child_setup): Fix size in write call.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1031 write (1, "Can't exec program: ", 20); |
296 | 1032 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
|
1033 write (1, "\n", 1); |
296 | 1034 _exit (1); |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1035 #endif /* not WINDOWSNT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
1036 #endif /* not MSDOS */ |
296 | 1037 } |
1038 | |
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1039 /* 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
|
1040 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
|
1041 int |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1042 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
|
1043 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
|
1044 { |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1045 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
|
1046 return fd; |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1047 else |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1048 { |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1049 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
|
1050 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
|
1051 { |
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
1052 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
|
1053 char *errmessage = strerror (errno); |
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
1054 char *message2 = "\n"; |
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
1055 write (2, message1, strlen (message1)); |
5516
ec5a245c14ed
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
5501
diff
changeset
|
1056 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
|
1057 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
|
1058 _exit (1); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1059 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1060 /* 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
|
1061 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
|
1062 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
|
1063 close (fd); |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1064 return new; |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1065 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1066 } |
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
1067 |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1068 static int |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1069 getenv_internal (var, varlen, value, valuelen) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1070 char *var; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1071 int varlen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1072 char **value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1073 int *valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1074 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1075 Lisp_Object scan; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1076 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1077 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
|
1078 { |
6495
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
1079 Lisp_Object entry; |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
1080 |
c88f34090aea
(call_process_cleanup, getenv_internal): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6466
diff
changeset
|
1081 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
|
1082 if (STRINGP (entry) |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1083 && XSTRING (entry)->size > varlen |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1084 && XSTRING (entry)->data[varlen] == '=' |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1085 #ifdef WINDOWSNT |
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1086 /* NT environment variables are case insensitive. */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
1087 && ! 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
|
1088 #else /* not WINDOWSNT */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
1089 && ! 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
|
1090 #endif /* not WINDOWSNT */ |
11393
81653012e0a6
(getenv_internal): Balance parentheses across #if/#endif.
Karl Heuer <kwzh@gnu.org>
parents:
11379
diff
changeset
|
1091 ) |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1092 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1093 *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
|
1094 *valuelen = XSTRING (entry)->size - (varlen + 1); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1095 return 1; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1096 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1097 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1098 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1099 return 0; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1100 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1101 |
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
1102 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
|
1103 "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
|
1104 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
|
1105 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
|
1106 (var) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1107 Lisp_Object var; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1108 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1109 char *value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1110 int valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1111 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1112 CHECK_STRING (var, 0); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1113 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
|
1114 &value, &valuelen)) |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1115 return make_string (value, valuelen); |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1116 else |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1117 return Qnil; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1118 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1119 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1120 /* 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
|
1121 callable from C. */ |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1122 char * |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1123 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
|
1124 char *var; |
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1125 { |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1126 char *value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1127 int valuelen; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1128 |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1129 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
|
1130 return value; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1131 else |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1132 return 0; |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1133 } |
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
1134 |
296 | 1135 #endif /* not VMS */ |
1136 | |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1137 /* 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
|
1138 |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1139 init_callproc_1 () |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1140 { |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1141 char *data_dir = egetenv ("EMACSDATA"); |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1142 char *doc_dir = egetenv ("EMACSDOC"); |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1143 |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1144 Vdata_directory |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
1145 = 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
|
1146 : PATH_DATA)); |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1147 Vdoc_directory |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1148 = 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
|
1149 : 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
|
1150 |
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
1151 /* 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
|
1152 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
|
1153 Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC); |
296 | 1154 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); |
1155 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
|
1156 } |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1157 |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1158 /* 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
|
1159 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1160 init_callproc () |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1161 { |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1162 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
|
1163 |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1164 register char * sh; |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1165 Lisp_Object tempdir; |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1166 |
5618
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1167 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
|
1168 { |
5618
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1169 /* 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
|
1170 Lisp_Object tem; |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1171 tem = Fexpand_file_name (build_string ("lib-src"), |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1172 Vinstallation_directory); |
a70dc7c886d0
(init_callproc): Use Vinstallation_directory.
Richard M. Stallman <rms@gnu.org>
parents:
5569
diff
changeset
|
1173 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
|
1174 { |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1175 #ifndef DOS_NT |
7824
de1dfb8aea82
(init_callproc) [MSDOS]: Exclude less code, so ../etc
Richard M. Stallman <rms@gnu.org>
parents:
7782
diff
changeset
|
1176 /* 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
|
1177 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
|
1178 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
|
1179 #endif /* not DOS_NT */ |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1180 } |
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1181 |
12615
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1182 /* 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
|
1183 if (data_dir == 0) |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1184 { |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1185 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
|
1186 Vinstallation_directory); |
d5db61e1a4ee
(init_callproc): Set Vdoc_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
12430
diff
changeset
|
1187 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
|
1188 } |
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
1189 } |
7465
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1190 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1191 /* 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
|
1192 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
|
1193 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
|
1194 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
|
1195 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1196 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
|
1197 source directory. */ |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1198 if (data_dir == 0) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1199 { |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1200 Lisp_Object tem, tem1, newdir; |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1201 |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1202 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
|
1203 tem1 = Ffile_exists_p (tem); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1204 if (NILP (tem1)) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1205 { |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1206 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
|
1207 build_string (PATH_DUMPLOADSEARCH)); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1208 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
|
1209 tem1 = Ffile_exists_p (tem); |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1210 if (!NILP (tem1)) |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1211 Vdata_directory = newdir; |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1212 } |
fccf9d4df7bb
(init_callproc): Never set Vdata_directory based on
Richard M. Stallman <rms@gnu.org>
parents:
7397
diff
changeset
|
1213 } |
296 | 1214 |
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
|
1215 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
|
1216 if (access (XSTRING (tempdir)->data, 0) < 0) |
16486
30b8c014eaa7
(init_callproc): Use dir_warning.
Richard M. Stallman <rms@gnu.org>
parents:
15824
diff
changeset
|
1217 dir_warning ("Warning: arch-dependent data dir (%s) does not exist.\n", |
30b8c014eaa7
(init_callproc): Use dir_warning.
Richard M. Stallman <rms@gnu.org>
parents:
15824
diff
changeset
|
1218 Vexec_directory); |
296 | 1219 |
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
|
1220 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
|
1221 if (access (XSTRING (tempdir)->data, 0) < 0) |
16486
30b8c014eaa7
(init_callproc): Use dir_warning.
Richard M. Stallman <rms@gnu.org>
parents:
15824
diff
changeset
|
1222 dir_warning ("Warning: arch-independent data dir (%s) does not exist.\n", |
30b8c014eaa7
(init_callproc): Use dir_warning.
Richard M. Stallman <rms@gnu.org>
parents:
15824
diff
changeset
|
1223 Vdata_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
|
1224 |
296 | 1225 #ifdef VMS |
1226 Vshell_file_name = build_string ("*dcl*"); | |
1227 #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
|
1228 sh = (char *) getenv ("SHELL"); |
296 | 1229 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); |
1230 #endif | |
16627
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1231 |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1232 #ifdef VMS |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1233 Vtemp_file_name_pattern = build_string ("tmp:emacsXXXXXX."); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1234 #else |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1235 if (getenv ("TMPDIR")) |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1236 { |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1237 char *dir = getenv ("TMPDIR"); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1238 Vtemp_file_name_pattern |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1239 = Fexpand_file_name (build_string ("emacsXXXXXX"), |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1240 build_string (dir)); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1241 } |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1242 else |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1243 Vtemp_file_name_pattern = build_string ("/tmp/emacsXXXXXX"); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1244 #endif |
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1245 } |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1246 |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1247 set_process_environment () |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1248 { |
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
1249 register char **envp; |
296 | 1250 |
1251 Vprocess_environment = Qnil; | |
1252 #ifndef CANNOT_DUMP | |
1253 if (initialized) | |
1254 #endif | |
1255 for (envp = environ; *envp; envp++) | |
1256 Vprocess_environment = Fcons (build_string (*envp), | |
1257 Vprocess_environment); | |
1258 } | |
1259 | |
1260 syms_of_callproc () | |
1261 { | |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1262 #ifdef DOS_NT |
7397
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1263 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
|
1264 staticpro (&Qbuffer_file_type); |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1265 |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1266 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
|
1267 "*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
|
1268 Vbinary_process_input = Qnil; |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1269 |
e0ffa47f2ed4
[MSDOS]: Rename Vbinary_process to Vbinary_process_output.
Richard M. Stallman <rms@gnu.org>
parents:
7161
diff
changeset
|
1270 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
|
1271 "*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
|
1272 Vbinary_process_output = Qnil; |
9786
7f4b72244919
(getenv_internal) [WINDOWSNT]: Use strnicmp, not bcmp.
Richard M. Stallman <rms@gnu.org>
parents:
9609
diff
changeset
|
1273 #endif /* DOS_NT */ |
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
1274 |
296 | 1275 DEFVAR_LISP ("shell-file-name", &Vshell_file_name, |
1276 "*File name to load inferior shells from.\n\ | |
1277 Initialized from the SHELL environment variable."); | |
1278 | |
1279 DEFVAR_LISP ("exec-path", &Vexec_path, | |
1280 "*List of directories to search programs to run in subprocesses.\n\ | |
1281 Each element is a string (directory name) or nil (try default directory)."); | |
1282 | |
1283 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
|
1284 "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
|
1285 especially executable programs intended for Emacs to invoke."); |
439 | 1286 |
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
|
1287 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
|
1288 "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
|
1289 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
|
1290 |
6031
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1291 DEFVAR_LISP ("doc-directory", &Vdoc_directory, |
ae4c6623837b
(syms_of_callproc): New variable Vdoc_directory.
Karl Heuer <kwzh@gnu.org>
parents:
5688
diff
changeset
|
1292 "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
|
1293 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
|
1294 |
3064
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1295 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
|
1296 "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
|
1297 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
|
1298 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
|
1299 includes this."); |
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
1300 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
|
1301 |
16627
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1302 DEFVAR_LISP ("temp-file-name-pattern", &Vtemp_file_name_pattern, |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1303 "Pattern for making names for temporary files.\n\ |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1304 This is used by `call-process-region'."); |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1305 /* The real initialization is when we start again. */ |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1306 Vtemp_file_name_pattern = Qnil; |
530b3f7373db
(Vtemp_file_name_pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16593
diff
changeset
|
1307 |
296 | 1308 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
|
1309 "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
|
1310 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
|
1311 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
|
1312 when Emacs starts."); |
296 | 1313 |
1314 #ifndef VMS | |
1315 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
|
1316 defsubr (&Sgetenv); |
296 | 1317 #endif |
1318 defsubr (&Scall_process_region); | |
1319 } |