Mercurial > emacs
annotate src/callproc.c @ 5501:902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
(init_callproc) [MSDOS]: Initialize binary-process.
[MSDOS]: Declare binary-process.
[MSDOS]: Include <fcntl.h>, <sys/stat.h>, <sys/param.h>,
and <errno.h> needed for the next changes.
(Fcall_process) [MSDOS]: Create temporary file for process output.
Run the subprocess using `run_msdos_command' instead of forking.
Arrange for cleanup to erase temporary file.
(Fcall_process) [not subprocesses]: Barf if zero buffer argument.
(call_process_cleanup) [MSDOS]: Close and erase temporary file
instead of the pid-stuff.
(Fcall_process_region) [MSDOS]: Create temporary file in $TMP or $TEMP.
(Fchild_setup) [MSDOS]: #if 0, as it is not used.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Sat, 08 Jan 1994 09:21:13 +0000 |
| parents | f921e3c48dcb |
| children | ec5a245c14ed |
| rev | line source |
|---|---|
| 296 | 1 /* Synchronous subprocess invocation for GNU Emacs. |
| 2961 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993 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 | |
| 8 the Free Software Foundation; either version 1, or (at your option) | |
| 9 any later version. | |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
| 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 19 | |
| 20 | |
| 21 #include <signal.h> | |
|
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
22 #include <errno.h> |
| 296 | 23 |
|
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
3932
diff
changeset
|
24 #include <config.h> |
| 296 | 25 |
|
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
26 extern int errno; |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
27 #ifndef VMS |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
28 extern char *sys_errlist[]; |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
29 #endif |
|
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 | |
| 41 #include <fcntl.h> | |
| 42 #endif | |
| 43 | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
44 #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
|
45 #include <fcntl.h> |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
46 #include <sys/stat.h> |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
47 #include <sys/param.h> |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
48 #include <errno.h> |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
49 #endif /* MSDOS */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
50 |
| 296 | 51 #ifndef O_RDONLY |
| 52 #define O_RDONLY 0 | |
| 53 #endif | |
| 54 | |
| 55 #ifndef O_WRONLY | |
| 56 #define O_WRONLY 1 | |
| 57 #endif | |
| 58 | |
| 59 #include "lisp.h" | |
| 60 #include "commands.h" | |
| 61 #include "buffer.h" | |
|
4701
05f6a91c2801
Include <paths.h>, not "paths.h".
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
62 #include <paths.h> |
| 296 | 63 #include "process.h" |
|
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
64 #include "syssignal.h" |
| 5348 | 65 #include "systty.h" |
| 296 | 66 |
| 67 #ifdef VMS | |
| 68 extern noshare char **environ; | |
| 69 #else | |
| 70 extern char **environ; | |
| 71 #endif | |
| 72 | |
| 73 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 74 | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
75 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
76 Lisp_Object Vbinary_process; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
77 #endif |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
78 |
|
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
|
79 Lisp_Object Vexec_path, Vexec_directory, Vdata_directory; |
|
3064
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
80 Lisp_Object Vconfigure_info_directory; |
| 296 | 81 |
| 82 Lisp_Object Vshell_file_name; | |
| 83 | |
| 84 Lisp_Object Vprocess_environment; | |
| 85 | |
| 86 /* True iff we are about to fork off a synchronous process or if we | |
| 87 are waiting for it. */ | |
| 88 int synch_process_alive; | |
| 89 | |
| 90 /* Nonzero => this is a string explaining death of synchronous subprocess. */ | |
| 91 char *synch_process_death; | |
| 92 | |
| 93 /* If synch_process_death is zero, | |
| 94 this is exit code of synchronous subprocess. */ | |
| 95 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
|
96 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
97 extern Lisp_Object Vdoc_file_name; |
| 296 | 98 |
| 99 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
| 100 | |
|
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
101 static Lisp_Object |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
102 call_process_kill (fdpid) |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
103 Lisp_Object fdpid; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
104 { |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
105 close (XFASTINT (Fcar (fdpid))); |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
106 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
|
107 synch_process_alive = 0; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
108 return Qnil; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
109 } |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
110 |
| 296 | 111 Lisp_Object |
| 112 call_process_cleanup (fdpid) | |
| 113 Lisp_Object fdpid; | |
| 114 { | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
115 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
116 /* for MSDOS fdpid is really (fd . tempfile) */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
117 register Lisp_Object file = Fcdr (fdpid); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
118 close (XFASTINT (Fcar (fdpid))); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
119 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
|
120 unlink (XSTRING (file)->data); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
121 #else /* not MSDOS */ |
|
1504
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
122 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
|
123 |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
124 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
|
125 { |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 immediate_quit = 1; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
130 QUIT; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
131 wait_for_termination (pid); |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
132 immediate_quit = 0; |
|
e074a2236b00
* callproc.c: Arrange for synchronous processes to get SIGINT the
Jim Blandy <jimb@redhat.com>
parents:
1201
diff
changeset
|
133 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
|
134 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
|
135 } |
| 296 | 136 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
|
137 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
|
138 #endif /* not MSDOS */ |
| 296 | 139 return Qnil; |
| 140 } | |
| 141 | |
| 142 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0, | |
| 143 "Call PROGRAM synchronously in separate process.\n\ | |
| 144 The program's input comes from file INFILE (nil means `/dev/null').\n\ | |
| 145 Insert output in BUFFER before point; t means current buffer;\n\ | |
| 146 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
| 147 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ | |
| 148 Remaining arguments are strings passed as command arguments to PROGRAM.\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
|
149 If BUFFER is 0, returns immediately with value nil.\n\ |
| 296 | 150 Otherwise 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
|
151 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
|
152 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
| 296 | 153 (nargs, args) |
| 154 int nargs; | |
| 155 register Lisp_Object *args; | |
| 156 { | |
|
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
157 Lisp_Object infile, buffer, current_dir, display, path; |
| 296 | 158 int fd[2]; |
| 159 int filefd; | |
| 160 register int pid; | |
| 161 char buf[1024]; | |
| 162 int count = specpdl_ptr - specpdl; | |
| 163 register unsigned char **new_argv | |
| 164 = (unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *)); | |
| 165 struct buffer *old = current_buffer; | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
166 #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
|
167 char *outf, *tempfile; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
168 int outfilefd; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
169 #endif |
| 296 | 170 #if 0 |
| 171 int mask; | |
| 172 #endif | |
| 173 CHECK_STRING (args[0], 0); | |
| 174 | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
175 #ifndef subprocesses |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
176 /* Without asynchronous processes we cannot have BUFFER == 0. */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
177 if (nargs >= 3 && XTYPE (args[2]) == Lisp_Int) |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
178 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
|
179 #endif /* subprocesses */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
180 |
|
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
|
181 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
|
182 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
183 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
|
184 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
|
185 } |
| 296 | 186 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
|
187 infile = build_string (NULL_DEVICE); |
| 648 | 188 |
|
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
|
189 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
|
190 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
191 register Lisp_Object tem; |
| 296 | 192 |
|
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
193 buffer = tem = args[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
|
194 if (!(EQ (tem, 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
|
195 || EQ (tem, Qt) |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
196 || XFASTINT (tem) == 0)) |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
197 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
198 buffer = Fget_buffer (tem); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
199 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
|
200 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
201 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
202 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
|
203 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
|
204 |
|
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
205 /* 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
|
206 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
|
207 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
|
208 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
|
209 |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
210 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
|
211 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
|
212 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
|
213 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
|
214 buffer. */ |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
215 { |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
216 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
|
217 |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
218 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
|
219 |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
220 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
|
221 |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
222 current_dir = |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
223 expand_and_dir_to_file |
|
1886
dd2e31cbf205
* process.c (Fstart_process): Jimb's change of December 11
Michael I. Bushnell <mib@gnu.org>
parents:
1678
diff
changeset
|
224 (Funhandled_file_name_directory (current_dir), Qnil); |
|
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
229 UNGCPRO; |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
230 } |
|
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
231 |
|
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
|
232 display = nargs >= 4 ? args[3] : Qnil; |
| 296 | 233 |
| 234 { | |
| 235 register int i; | |
| 236 for (i = 4; i < nargs; i++) | |
| 237 { | |
| 238 CHECK_STRING (args[i], i); | |
| 239 new_argv[i - 3] = XSTRING (args[i])->data; | |
| 240 } | |
| 241 /* Program name is first command arg */ | |
| 242 new_argv[0] = XSTRING (args[0])->data; | |
| 243 new_argv[i - 3] = 0; | |
| 244 } | |
| 245 | |
|
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
|
246 filefd = open (XSTRING (infile)->data, O_RDONLY, 0); |
| 296 | 247 if (filefd < 0) |
| 248 { | |
|
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
|
249 report_file_error ("Opening process input file", Fcons (infile, Qnil)); |
| 296 | 250 } |
| 251 /* Search for program; barf if not found. */ | |
|
2432
17a84e60603b
New macros NULL_DEVICE and EXEC_SUFFIXES, to give the name of the
Jim Blandy <jimb@redhat.com>
parents:
2286
diff
changeset
|
252 openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 1); |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
253 if (NILP (path)) |
| 296 | 254 { |
| 255 close (filefd); | |
| 256 report_file_error ("Searching for program", Fcons (args[0], Qnil)); | |
| 257 } | |
| 258 new_argv[0] = XSTRING (path)->data; | |
| 259 | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
260 #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
|
261 /* These vars record information from process termination. |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
262 Clear them now before process can possibly terminate, |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
263 to avoid timing error if process terminates soon. */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
264 synch_process_death = 0; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
265 synch_process_retcode = 0; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
266 |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
267 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
|
268 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
|
269 else |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
270 { |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
271 tempfile = alloca (20); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
272 *tempfile = '\0'; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
273 } |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
274 dostounix_filename (tempfile); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
275 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
|
276 strcat (tempfile, "/"); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
277 strcat (tempfile, "detmp.XXX"); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
278 mktemp (tempfile); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
279 |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
280 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
|
281 if (outfilefd < 0) |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
282 { |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
283 close (filefd); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
284 report_file_error ("Opening process output file", Fcons (tempfile, Qnil)); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
285 } |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
286 #endif |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
287 |
| 296 | 288 if (XTYPE (buffer) == Lisp_Int) |
|
2432
17a84e60603b
New macros NULL_DEVICE and EXEC_SUFFIXES, to give the name of the
Jim Blandy <jimb@redhat.com>
parents:
2286
diff
changeset
|
289 fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; |
| 296 | 290 else |
| 291 { | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
292 #ifndef MSDOS |
| 296 | 293 pipe (fd); |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
294 #endif |
| 296 | 295 #if 0 |
| 296 /* Replaced by close_process_descs */ | |
| 297 set_exclusive_use (fd[0]); | |
| 298 #endif | |
| 299 } | |
| 300 | |
| 301 { | |
| 302 /* child_setup must clobber environ in systems with true vfork. | |
| 303 Protect it from permanent change. */ | |
| 304 register char **save_environ = environ; | |
| 305 register int fd1 = fd[1]; | |
| 306 | |
| 307 #if 0 /* Some systems don't have sigblock. */ | |
| 638 | 308 mask = sigblock (sigmask (SIGCHLD)); |
| 296 | 309 #endif |
| 310 | |
| 311 /* Record that we're about to create a synchronous process. */ | |
| 312 synch_process_alive = 1; | |
| 313 | |
|
4977
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
314 /* 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
|
315 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
|
316 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
|
317 synch_process_death = 0; |
|
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
318 synch_process_retcode = 0; |
|
81c44a01ddda
(Fcall_process): Clear synch_process_death and
Richard M. Stallman <rms@gnu.org>
parents:
4701
diff
changeset
|
319 |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
320 #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
|
321 pid = run_msdos_command (new_argv, current_dir, filefd, outfilefd); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
322 close (outfilefd); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
323 fd1 = -1; /* No harm in closing that one! */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
324 fd[0] = open (tempfile, NILP (Vbinary_process) ? O_TEXT : O_BINARY); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
325 if (fd[0] < 0) |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
326 { |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
327 unlink (tempfile); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
328 report_file_error ("Cannot re-open temporary file", Qnil); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
329 } |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
330 #else /* not MSDOS */ |
| 296 | 331 pid = vfork (); |
| 332 | |
| 333 if (pid == 0) | |
| 334 { | |
| 335 if (fd[0] >= 0) | |
| 336 close (fd[0]); | |
|
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3814
diff
changeset
|
337 #ifdef USG |
| 296 | 338 setpgrp (); |
| 339 #else | |
| 340 setpgrp (pid, pid); | |
| 341 #endif /* USG */ | |
|
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
|
342 child_setup (filefd, fd1, fd1, new_argv, 0, current_dir); |
| 296 | 343 } |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
344 #endif /* not MSDOS */ |
| 296 | 345 |
| 346 #if 0 | |
| 347 /* Tell SIGCHLD handler to look for this pid. */ | |
| 348 synch_process_pid = pid; | |
| 349 /* Now let SIGCHLD come through. */ | |
| 638 | 350 sigsetmask (mask); |
| 296 | 351 #endif |
| 352 | |
| 353 environ = save_environ; | |
| 354 | |
| 355 close (filefd); | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
356 if (fd1 >= 0) |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
357 close (fd1); |
| 296 | 358 } |
| 359 | |
| 360 if (pid < 0) | |
| 361 { | |
| 362 close (fd[0]); | |
| 363 report_file_error ("Doing vfork", Qnil); | |
| 364 } | |
| 365 | |
| 366 if (XTYPE (buffer) == Lisp_Int) | |
| 367 { | |
| 368 #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
|
369 /* 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
|
370 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
|
371 the facilities for handling SIGCHLD. */ |
| 296 | 372 wait_without_blocking (); |
| 373 #endif /* subprocesses */ | |
| 374 return Qnil; | |
| 375 } | |
| 376 | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
377 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
378 /* 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
|
379 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
|
380 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
|
381 #else |
| 296 | 382 record_unwind_protect (call_process_cleanup, |
| 383 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
|
384 #endif /* not MSDOS */ |
| 296 | 385 |
| 386 | |
| 387 if (XTYPE (buffer) == Lisp_Buffer) | |
| 388 Fset_buffer (buffer); | |
| 389 | |
| 390 immediate_quit = 1; | |
| 391 QUIT; | |
| 392 | |
| 393 { | |
| 394 register int nread; | |
|
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
395 int first = 1; |
| 296 | 396 |
| 397 while ((nread = read (fd[0], buf, sizeof buf)) > 0) | |
| 398 { | |
| 399 immediate_quit = 0; | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
400 if (!NILP (buffer)) |
| 296 | 401 insert (buf, nread); |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
402 if (!NILP (display) && INTERACTIVE) |
|
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
403 { |
|
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
404 if (first) |
|
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
405 prepare_menu_bars (); |
|
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
406 first = 0; |
|
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
407 redisplay_preserve_echo_area (); |
|
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
408 } |
| 296 | 409 immediate_quit = 1; |
| 410 QUIT; | |
| 411 } | |
| 412 } | |
| 413 | |
| 414 /* Wait for it to terminate, unless it already has. */ | |
| 415 wait_for_termination (pid); | |
| 416 | |
| 417 immediate_quit = 0; | |
| 418 | |
| 419 set_buffer_internal (old); | |
| 420 | |
| 421 unbind_to (count, Qnil); | |
| 422 | |
| 423 if (synch_process_death) | |
| 424 return build_string (synch_process_death); | |
| 425 return make_number (synch_process_retcode); | |
| 426 } | |
| 427 #endif | |
| 428 | |
|
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
429 static Lisp_Object |
| 296 | 430 delete_temp_file (name) |
| 431 Lisp_Object name; | |
| 432 { | |
| 433 unlink (XSTRING (name)->data); | |
| 434 } | |
| 435 | |
| 436 DEFUN ("call-process-region", Fcall_process_region, Scall_process_region, | |
| 437 3, MANY, 0, | |
| 438 "Send text from START to END to a synchronous process running PROGRAM.\n\ | |
| 439 Delete the text if fourth arg DELETE is non-nil.\n\ | |
| 440 Insert output in BUFFER before point; t means current buffer;\n\ | |
| 441 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
| 442 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ | |
| 443 Remaining args are passed to PROGRAM at startup as command args.\n\ | |
| 444 If BUFFER is nil, returns immediately with value nil.\n\ | |
| 445 Otherwise 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
|
446 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
|
447 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") |
| 296 | 448 (nargs, args) |
| 449 int nargs; | |
| 450 register Lisp_Object *args; | |
| 451 { | |
| 452 register Lisp_Object filename_string, start, end; | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
453 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
454 char *tempfile; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
455 #else |
| 296 | 456 char tempfile[20]; |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
457 #endif |
| 296 | 458 int count = specpdl_ptr - specpdl; |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
459 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
460 char *outf = '\0'; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
461 |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
462 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
|
463 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
|
464 else |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
465 { |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
466 tempfile = alloca (20); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
467 *tempfile = '\0'; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
468 } |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
469 dostounix_filename (tempfile); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
470 if (tempfile[strlen (tempfile) - 1] != '/') |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
471 strcat (tempfile, "/"); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
472 strcat (tempfile, "detmp.XXX"); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
473 #else /* not MSDOS */ |
| 296 | 474 |
| 475 #ifdef VMS | |
| 476 strcpy (tempfile, "tmp:emacsXXXXXX."); | |
| 477 #else | |
| 478 strcpy (tempfile, "/tmp/emacsXXXXXX"); | |
| 479 #endif | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
480 #endif /* not MSDOS */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
481 |
| 296 | 482 mktemp (tempfile); |
| 483 | |
| 484 filename_string = build_string (tempfile); | |
| 485 start = args[0]; | |
| 486 end = args[1]; | |
| 487 Fwrite_region (start, end, filename_string, Qnil, Qlambda); | |
| 488 record_unwind_protect (delete_temp_file, filename_string); | |
| 489 | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
490 if (!NILP (args[3])) |
| 296 | 491 Fdelete_region (start, end); |
| 492 | |
| 493 args[3] = filename_string; | |
| 494 | |
|
1678
62ecf0c5b54c
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
495 return unbind_to (count, Fcall_process (nargs - 2, args + 2)); |
| 296 | 496 } |
| 497 | |
| 498 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
| 499 | |
| 500 /* This is the last thing run in a newly forked inferior | |
| 501 either synchronous or asynchronous. | |
| 502 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2. | |
| 503 Initialize inferior's priority, pgrp, connected dir and environment. | |
| 504 then exec another program based on new_argv. | |
| 505 | |
| 506 This function may change environ for the superior process. | |
| 507 Therefore, the superior process must save and restore the value | |
| 508 of environ around the vfork and the call to this function. | |
| 509 | |
| 510 ENV is the environment for the subprocess. | |
| 511 | |
| 512 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
|
513 process group. |
| 296 | 514 |
|
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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
520 child_setup (in, out, err, new_argv, set_pgrp, current_dir) |
| 296 | 521 int in, out, err; |
| 522 register char **new_argv; | |
| 523 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
|
524 Lisp_Object current_dir; |
| 296 | 525 { |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
526 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
527 /* 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
|
528 instead. */ |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
529 #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
|
530 char **env; |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
531 |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
532 register int pid = getpid (); |
| 296 | 533 |
|
1201
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
534 { |
|
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
535 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
|
536 |
|
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
537 nice (- emacs_priority); |
|
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
538 } |
| 296 | 539 |
| 540 #ifdef subprocesses | |
| 541 /* Close Emacs's descriptors that this process should not have. */ | |
| 542 close_process_descs (); | |
| 543 #endif | |
| 544 | |
| 545 /* Note that use of alloca is always safe here. It's obvious for systems | |
| 546 that do not have true vfork or that have true (stack) alloca. | |
| 547 If using vfork and C_ALLOCA it is safe because that changes | |
| 548 the superior's static variables as if the superior had done alloca | |
| 549 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
|
550 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
551 register unsigned char *temp; |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
552 register int i; |
| 296 | 553 |
|
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
|
554 i = XSTRING (current_dir)->size; |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
555 temp = (unsigned char *) alloca (i + 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
|
556 bcopy (XSTRING (current_dir)->data, temp, i); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
557 if (temp[i - 1] != '/') temp[i++] = '/'; |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
558 temp[i] = 0; |
| 538 | 559 |
|
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
|
560 /* 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 if (chdir (temp) < 0) |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
566 exit (errno); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
567 } |
| 296 | 568 |
| 569 /* Set `env' to a vector of the strings in Vprocess_environment. */ | |
| 570 { | |
| 571 register Lisp_Object tem; | |
| 572 register char **new_env; | |
| 573 register int new_length; | |
| 574 | |
| 575 new_length = 0; | |
| 576 for (tem = Vprocess_environment; | |
| 577 (XTYPE (tem) == Lisp_Cons | |
| 578 && XTYPE (XCONS (tem)->car) == Lisp_String); | |
| 579 tem = XCONS (tem)->cdr) | |
| 580 new_length++; | |
| 581 | |
|
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
582 /* new_length + 1 to include terminating 0. */ |
| 296 | 583 env = new_env = (char **) alloca ((new_length + 1) * sizeof (char *)); |
| 584 | |
|
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
585 /* Copy the Vprocess_environment strings into new_env. */ |
| 296 | 586 for (tem = Vprocess_environment; |
| 587 (XTYPE (tem) == Lisp_Cons | |
| 588 && XTYPE (XCONS (tem)->car) == Lisp_String); | |
| 589 tem = XCONS (tem)->cdr) | |
|
2757
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
590 { |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
591 char **ep = env; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
592 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
|
593 /* 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
|
594 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
|
595 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
|
596 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
|
597 for (; ep != new_env; ep++) |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
598 { |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
599 char *p = *ep, *q = string; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
600 while (1) |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
601 { |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
602 if (*q == 0) |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
603 /* 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
|
604 goto duplicate; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
605 if (*q != *p) |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
606 break; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
607 if (*q == '=') |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
608 goto duplicate; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
609 p++, q++; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
610 } |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
611 } |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
612 *new_env++ = string; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
613 duplicate: ; |
|
a3ee51f30431
(child_setup): Omit duplicates from new env array.
Richard M. Stallman <rms@gnu.org>
parents:
2509
diff
changeset
|
614 } |
| 296 | 615 *new_env = 0; |
| 616 } | |
| 617 | |
|
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
618 /* 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
|
619 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
|
620 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
|
621 happen under X. */ |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
622 in = relocate_fd (in, 3); |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
623 out = relocate_fd (out, 3); |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
624 err = relocate_fd (err, 3); |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
625 |
| 296 | 626 close (0); |
| 627 close (1); | |
| 628 close (2); | |
| 629 | |
| 630 dup2 (in, 0); | |
| 631 dup2 (out, 1); | |
| 632 dup2 (err, 2); | |
| 633 close (in); | |
| 634 close (out); | |
| 635 close (err); | |
| 636 | |
|
5179
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
637 #ifdef USG |
|
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
638 #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
|
639 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
|
640 #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
|
641 #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
|
642 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
|
643 #endif /* USG */ |
| 5348 | 644 /* setpgrp_of_tty is incorrect here; it uses input_fd. */ |
| 645 EMACS_SET_TTY_PGRP (0, &pid); | |
| 296 | 646 |
| 647 #ifdef vipc | |
| 648 something missing here; | |
| 649 #endif /* vipc */ | |
| 650 | |
| 651 /* execvp does not accept an environment arg so the only way | |
| 652 to pass this environment is to set environ. Our caller | |
| 653 is responsible for restoring the ambient value of environ. */ | |
| 654 environ = env; | |
| 655 execvp (new_argv[0], new_argv); | |
| 656 | |
| 657 write (1, "Couldn't exec the program ", 26); | |
| 658 write (1, new_argv[0], strlen (new_argv[0])); | |
| 659 _exit (1); | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
660 #endif /* not MSDOS */ |
| 296 | 661 } |
| 662 | |
|
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
663 /* 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
|
664 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
|
665 int |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
666 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
|
667 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
|
668 { |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
669 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
|
670 return fd; |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
671 else |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
672 { |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
673 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
|
674 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
|
675 { |
|
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
676 char *message1 = "Error while setting up child: "; |
|
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
677 char *message2 = "\n"; |
|
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
678 write (2, message1, strlen (message1)); |
|
2286
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
679 write (2, sys_errlist[errno], strlen (sys_errlist[errno])); |
|
2509
daaa78c8c980
* callproc.c (relocate_fd): Make messages string literals, not
Jim Blandy <jimb@redhat.com>
parents:
2432
diff
changeset
|
680 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
|
681 _exit (1); |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
682 } |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
683 /* 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
|
684 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
|
685 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
|
686 close (fd); |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
687 return new; |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
688 } |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
689 } |
|
7f66b40a0192
* callproc.c (child_setup): Make sure that in, out, and err are
Jim Blandy <jimb@redhat.com>
parents:
1912
diff
changeset
|
690 |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
691 static int |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
692 getenv_internal (var, varlen, value, valuelen) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
693 char *var; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
694 int varlen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
695 char **value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
696 int *valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
697 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
698 Lisp_Object scan; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
699 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
700 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
|
701 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
702 Lisp_Object entry = XCONS (scan)->car; |
|
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
|
703 |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
704 if (XTYPE (entry) == Lisp_String |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
705 && XSTRING (entry)->size > varlen |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
706 && XSTRING (entry)->data[varlen] == '=' |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
707 && ! bcmp (XSTRING (entry)->data, var, varlen)) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
708 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
709 *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
|
710 *valuelen = XSTRING (entry)->size - (varlen + 1); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
711 return 1; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
712 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
713 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
714 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
715 return 0; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
716 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
717 |
|
5251
480731ff8e9a
(Fcall_process): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5179
diff
changeset
|
718 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
|
719 "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
|
720 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
|
721 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
|
722 (var) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
723 Lisp_Object var; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
724 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
725 char *value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
726 int valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
727 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
728 CHECK_STRING (var, 0); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
729 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
|
730 &value, &valuelen)) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
731 return make_string (value, valuelen); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
732 else |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
733 return Qnil; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
734 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
735 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
736 /* 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
|
737 callable from C. */ |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
738 char * |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
739 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
|
740 char *var; |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
741 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
742 char *value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
743 int valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
744 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
745 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
|
746 return value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
747 else |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
748 return 0; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
749 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
750 |
| 296 | 751 #endif /* not VMS */ |
| 752 | |
|
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
753 /* 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
|
754 |
|
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
755 init_callproc_1 () |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
756 { |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
757 char *data_dir = egetenv ("EMACSDATA"); |
|
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
758 |
|
5154
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
759 Vdata_directory |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
760 = 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
|
761 : PATH_DATA)); |
|
948
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
762 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
763 /* 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
|
764 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
|
765 Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC); |
| 296 | 766 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); |
| 767 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
|
768 } |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
769 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
770 /* This is run after init_cmdargs, so that Vinvocation_directory is valid. */ |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
771 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
772 init_callproc () |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
773 { |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
774 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
|
775 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
776 register char * sh; |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
777 Lisp_Object tempdir; |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
778 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
779 if (initialized && !NILP (Vinvocation_directory)) |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
780 { |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
781 /* Add to the path the ../lib-src dir of the Emacs executable, |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
782 if that dir exists. */ |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
783 Lisp_Object tem, tem1; |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
784 tem = Fexpand_file_name (build_string ("../lib-src"), |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
785 Vinvocation_directory); |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
786 tem1 = Ffile_exists_p (tem); |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
787 if (!NILP (tem1) && NILP (Fmember (tem, Vexec_path))) |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
788 { |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
789 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
|
790 Vexec_directory = Ffile_name_as_directory (tem); |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
791 |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
792 /* If we use ../lib-src, maybe use ../etc as well. |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
793 Do so if ../etc exists and has our DOC-... file in it. */ |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
794 if (data_dir == 0) |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
795 { |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
796 Lisp_Object tem, tem2, tem3; |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
797 tem = Fexpand_file_name (build_string ("../etc"), |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
798 Vinvocation_directory); |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
799 tem2 = Fexpand_file_name (Vdoc_file_name, tem); |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
800 tem3 = Ffile_exists_p (tem2); |
|
5179
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
801 if (!NILP (tem3)) |
|
2a1492764d5e
(child_setup): Test SETPGRP_RELEASES_CTTY, not IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5154
diff
changeset
|
802 Vdata_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
|
803 } |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
804 } |
|
e4e66bcaa016
(init_callproc): Maybe add ../lib-src to exec-path
Richard M. Stallman <rms@gnu.org>
parents:
4977
diff
changeset
|
805 } |
| 296 | 806 |
|
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
|
807 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
|
808 if (access (XSTRING (tempdir)->data, 0) < 0) |
| 296 | 809 { |
|
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
|
810 printf ("Warning: arch-dependent data dir (%s) does not exist.\n", |
| 296 | 811 XSTRING (Vexec_directory)->data); |
| 812 sleep (2); | |
| 813 } | |
| 814 | |
|
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
|
815 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
|
816 if (access (XSTRING (tempdir)->data, 0) < 0) |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
817 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
818 printf ("Warning: arch-independent data dir (%s) does not exist.\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
|
819 XSTRING (Vdata_directory)->data); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
820 sleep (2); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
821 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
822 |
| 296 | 823 #ifdef VMS |
| 824 Vshell_file_name = build_string ("*dcl*"); | |
| 825 #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
|
826 sh = (char *) getenv ("SHELL"); |
| 296 | 827 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); |
| 828 #endif | |
|
1912
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
829 } |
|
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
830 |
|
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
831 set_process_environment () |
|
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
832 { |
|
f0d4fb2b9157
* callproc.c (delete_temp_file): Declare this to return
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
833 register char **envp; |
| 296 | 834 |
| 835 Vprocess_environment = Qnil; | |
| 836 #ifndef CANNOT_DUMP | |
| 837 if (initialized) | |
| 838 #endif | |
| 839 for (envp = environ; *envp; envp++) | |
| 840 Vprocess_environment = Fcons (build_string (*envp), | |
| 841 Vprocess_environment); | |
| 842 } | |
| 843 | |
| 844 syms_of_callproc () | |
| 845 { | |
|
5501
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
846 #ifdef MSDOS |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
847 DEFVAR_LISP ("binary-process", &Vbinary_process, |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
848 "*If non-nil then new subprocesses are assumed to produce binary output."); |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
849 Vbinary_process = Qnil; |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
850 #endif |
|
902cd7024cfa
(syms_of_callproc) [MSDOS]: New lisp variable: binary-process.
Richard M. Stallman <rms@gnu.org>
parents:
5348
diff
changeset
|
851 |
| 296 | 852 DEFVAR_LISP ("shell-file-name", &Vshell_file_name, |
| 853 "*File name to load inferior shells from.\n\ | |
| 854 Initialized from the SHELL environment variable."); | |
| 855 | |
| 856 DEFVAR_LISP ("exec-path", &Vexec_path, | |
| 857 "*List of directories to search programs to run in subprocesses.\n\ | |
| 858 Each element is a string (directory name) or nil (try default directory)."); | |
| 859 | |
| 860 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
|
861 "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
|
862 especially executable programs intended for Emacs to invoke."); |
| 439 | 863 |
|
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 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
|
865 "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
|
866 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
|
867 |
|
3064
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
868 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
|
869 "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
|
870 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
|
871 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
|
872 includes this."); |
|
fa5466904709
* paths.h (PATH_INFO): New path, to edited by the configuration
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
873 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
|
874 |
| 296 | 875 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
|
876 "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
|
877 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
|
878 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
|
879 when Emacs starts."); |
| 296 | 880 |
| 881 #ifndef VMS | |
| 882 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
|
883 defsubr (&Sgetenv); |
| 296 | 884 #endif |
| 885 defsubr (&Scall_process_region); | |
| 886 } |
