Mercurial > emacs
annotate src/callproc.c @ 1201:4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
simple, portable call to nice here.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Wed, 23 Sep 1992 03:43:10 +0000 |
| parents | 928ed74adf4f |
| children | e074a2236b00 |
| rev | line source |
|---|---|
| 296 | 1 /* Synchronous subprocess invocation for GNU Emacs. |
|
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
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1992 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 |
| 24 #include "config.h" | |
| 25 | |
| 26 /* Define SIGCHLD as an alias for SIGCLD. */ | |
| 27 | |
| 28 #if !defined (SIGCHLD) && defined (SIGCLD) | |
| 29 #define SIGCHLD SIGCLD | |
| 30 #endif /* SIGCLD */ | |
| 31 | |
| 32 #include <sys/types.h> | |
| 33 #define PRIO_PROCESS 0 | |
| 34 #include <sys/file.h> | |
| 35 #ifdef USG5 | |
| 36 #include <fcntl.h> | |
| 37 #endif | |
| 38 | |
| 39 #ifndef O_RDONLY | |
| 40 #define O_RDONLY 0 | |
| 41 #endif | |
| 42 | |
| 43 #ifndef O_WRONLY | |
| 44 #define O_WRONLY 1 | |
| 45 #endif | |
| 46 | |
| 47 #include "lisp.h" | |
| 48 #include "commands.h" | |
| 49 #include "buffer.h" | |
| 50 #include "paths.h" | |
| 51 #include "process.h" | |
| 52 | |
| 53 #ifdef VMS | |
| 54 extern noshare char **environ; | |
| 55 #else | |
| 56 extern char **environ; | |
| 57 #endif | |
| 58 | |
| 59 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
| 60 | |
|
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
|
61 Lisp_Object Vexec_path, Vexec_directory, Vdata_directory; |
| 296 | 62 |
| 63 Lisp_Object Vshell_file_name; | |
| 64 | |
| 65 Lisp_Object Vprocess_environment; | |
| 66 | |
| 67 /* True iff we are about to fork off a synchronous process or if we | |
| 68 are waiting for it. */ | |
| 69 int synch_process_alive; | |
| 70 | |
| 71 /* Nonzero => this is a string explaining death of synchronous subprocess. */ | |
| 72 char *synch_process_death; | |
| 73 | |
| 74 /* If synch_process_death is zero, | |
| 75 this is exit code of synchronous subprocess. */ | |
| 76 int synch_process_retcode; | |
| 77 | |
| 78 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
| 79 | |
| 80 Lisp_Object | |
| 81 call_process_cleanup (fdpid) | |
| 82 Lisp_Object fdpid; | |
| 83 { | |
| 84 register Lisp_Object fd, pid; | |
| 85 fd = Fcar (fdpid); | |
| 86 pid = Fcdr (fdpid); | |
| 87 close (XFASTINT (fd)); | |
| 88 kill (XFASTINT (pid), SIGKILL); | |
| 89 synch_process_alive = 0; | |
| 90 return Qnil; | |
| 91 } | |
| 92 | |
| 93 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0, | |
| 94 "Call PROGRAM synchronously in separate process.\n\ | |
| 95 The program's input comes from file INFILE (nil means `/dev/null').\n\ | |
| 96 Insert output in BUFFER before point; t means current buffer;\n\ | |
| 97 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
| 98 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ | |
| 99 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
|
100 If BUFFER is 0, returns immediately with value nil.\n\ |
| 296 | 101 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
|
102 and returns a numeric exit status or a signal description string.\n\ |
| 296 | 103 If you quit, the process is killed with SIGKILL.") |
| 104 (nargs, args) | |
| 105 int nargs; | |
| 106 register Lisp_Object *args; | |
| 107 { | |
|
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
|
108 Lisp_Object display, infile, buffer, path, current_dir; |
| 296 | 109 int fd[2]; |
| 110 int filefd; | |
| 111 register int pid; | |
| 112 char buf[1024]; | |
| 113 int count = specpdl_ptr - specpdl; | |
| 114 register unsigned char **new_argv | |
| 115 = (unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *)); | |
| 116 struct buffer *old = current_buffer; | |
| 117 #if 0 | |
| 118 int mask; | |
| 119 #endif | |
| 120 CHECK_STRING (args[0], 0); | |
| 121 | |
|
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
|
122 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
|
123 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
124 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
|
125 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
|
126 } |
| 296 | 127 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
|
128 #ifdef VMS |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
129 infile = build_string ("NLA0:"); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
130 #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
|
131 infile = build_string ("/dev/null"); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
132 #endif /* not VMS */ |
| 648 | 133 |
|
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
|
134 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
|
135 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
136 register Lisp_Object tem; |
| 296 | 137 |
|
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
|
138 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
|
139 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
|
140 || 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
|
141 || 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
|
142 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
143 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
|
144 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
|
145 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
146 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
147 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
|
148 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
|
149 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
150 display = nargs >= 4 ? args[3] : Qnil; |
| 296 | 151 |
| 152 { | |
| 153 register int i; | |
| 154 for (i = 4; i < nargs; i++) | |
| 155 { | |
| 156 CHECK_STRING (args[i], i); | |
| 157 new_argv[i - 3] = XSTRING (args[i])->data; | |
| 158 } | |
| 159 /* Program name is first command arg */ | |
| 160 new_argv[0] = XSTRING (args[0])->data; | |
| 161 new_argv[i - 3] = 0; | |
| 162 } | |
| 163 | |
|
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
|
164 filefd = open (XSTRING (infile)->data, O_RDONLY, 0); |
| 296 | 165 if (filefd < 0) |
| 166 { | |
|
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
|
167 report_file_error ("Opening process input file", Fcons (infile, Qnil)); |
| 296 | 168 } |
| 169 /* Search for program; barf if not found. */ | |
| 170 openp (Vexec_path, args[0], "", &path, 1); | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
171 if (NILP (path)) |
| 296 | 172 { |
| 173 close (filefd); | |
| 174 report_file_error ("Searching for program", Fcons (args[0], Qnil)); | |
| 175 } | |
| 176 new_argv[0] = XSTRING (path)->data; | |
| 177 | |
| 178 if (XTYPE (buffer) == Lisp_Int) | |
| 179 fd[1] = open ("/dev/null", O_WRONLY), fd[0] = -1; | |
| 180 else | |
| 181 { | |
| 182 pipe (fd); | |
| 183 #if 0 | |
| 184 /* Replaced by close_process_descs */ | |
| 185 set_exclusive_use (fd[0]); | |
| 186 #endif | |
| 187 } | |
| 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 /* Make sure that the child will be able to chdir to 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
|
190 buffer's current directory. We can't just have the child 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
|
191 for an error when it does the chdir, since it's in a vfork. */ |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
192 current_dir = expand_and_dir_to_file (current_buffer->directory, 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
|
193 if (NILP (Ffile_accessible_directory_p (current_dir))) |
|
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 report_file_error ("Setting current 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
|
195 Fcons (current_buffer->directory, 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
|
196 |
| 296 | 197 { |
| 198 /* child_setup must clobber environ in systems with true vfork. | |
| 199 Protect it from permanent change. */ | |
| 200 register char **save_environ = environ; | |
| 201 register int fd1 = fd[1]; | |
| 202 | |
| 203 #if 0 /* Some systems don't have sigblock. */ | |
| 638 | 204 mask = sigblock (sigmask (SIGCHLD)); |
| 296 | 205 #endif |
| 206 | |
| 207 /* Record that we're about to create a synchronous process. */ | |
| 208 synch_process_alive = 1; | |
| 209 | |
| 210 pid = vfork (); | |
| 211 | |
| 212 if (pid == 0) | |
| 213 { | |
| 214 if (fd[0] >= 0) | |
| 215 close (fd[0]); | |
| 216 #ifdef USG | |
| 217 setpgrp (); | |
| 218 #else | |
| 219 setpgrp (pid, pid); | |
| 220 #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
|
221 child_setup (filefd, fd1, fd1, new_argv, 0, current_dir); |
| 296 | 222 } |
| 223 | |
| 224 #if 0 | |
| 225 /* Tell SIGCHLD handler to look for this pid. */ | |
| 226 synch_process_pid = pid; | |
| 227 /* Now let SIGCHLD come through. */ | |
| 638 | 228 sigsetmask (mask); |
| 296 | 229 #endif |
| 230 | |
| 231 environ = save_environ; | |
| 232 | |
| 233 close (filefd); | |
| 234 close (fd1); | |
| 235 } | |
| 236 | |
| 237 if (pid < 0) | |
| 238 { | |
| 239 close (fd[0]); | |
| 240 report_file_error ("Doing vfork", Qnil); | |
| 241 } | |
| 242 | |
| 243 if (XTYPE (buffer) == Lisp_Int) | |
| 244 { | |
| 245 #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
|
246 /* 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
|
247 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
|
248 the facilities for handling SIGCHLD. */ |
| 296 | 249 wait_without_blocking (); |
| 250 #endif /* subprocesses */ | |
| 251 return Qnil; | |
| 252 } | |
| 253 | |
|
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
|
254 synch_process_death = 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
|
255 synch_process_retcode = 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
|
256 |
| 296 | 257 record_unwind_protect (call_process_cleanup, |
| 258 Fcons (make_number (fd[0]), make_number (pid))); | |
| 259 | |
| 260 | |
| 261 if (XTYPE (buffer) == Lisp_Buffer) | |
| 262 Fset_buffer (buffer); | |
| 263 | |
| 264 immediate_quit = 1; | |
| 265 QUIT; | |
| 266 | |
| 267 { | |
| 268 register int nread; | |
| 269 | |
| 270 while ((nread = read (fd[0], buf, sizeof buf)) > 0) | |
| 271 { | |
| 272 immediate_quit = 0; | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
273 if (!NILP (buffer)) |
| 296 | 274 insert (buf, nread); |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
275 if (!NILP (display) && INTERACTIVE) |
| 296 | 276 redisplay_preserve_echo_area (); |
| 277 immediate_quit = 1; | |
| 278 QUIT; | |
| 279 } | |
| 280 } | |
| 281 | |
| 282 /* Wait for it to terminate, unless it already has. */ | |
| 283 wait_for_termination (pid); | |
| 284 | |
| 285 immediate_quit = 0; | |
| 286 | |
| 287 set_buffer_internal (old); | |
| 288 | |
| 289 unbind_to (count, Qnil); | |
| 290 | |
| 291 if (synch_process_death) | |
| 292 return build_string (synch_process_death); | |
| 293 return make_number (synch_process_retcode); | |
| 294 } | |
| 295 #endif | |
| 296 | |
| 297 static void | |
| 298 delete_temp_file (name) | |
| 299 Lisp_Object name; | |
| 300 { | |
| 301 unlink (XSTRING (name)->data); | |
| 302 } | |
| 303 | |
| 304 DEFUN ("call-process-region", Fcall_process_region, Scall_process_region, | |
| 305 3, MANY, 0, | |
| 306 "Send text from START to END to a synchronous process running PROGRAM.\n\ | |
| 307 Delete the text if fourth arg DELETE is non-nil.\n\ | |
| 308 Insert output in BUFFER before point; t means current buffer;\n\ | |
| 309 nil for BUFFER means discard it; 0 means discard and don't wait.\n\ | |
| 310 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.\n\ | |
| 311 Remaining args are passed to PROGRAM at startup as command args.\n\ | |
| 312 If BUFFER is nil, returns immediately with value nil.\n\ | |
| 313 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
|
314 and returns a numeric exit status or a signal description string.\n\ |
| 296 | 315 If you quit, the process is killed with SIGKILL.") |
| 316 (nargs, args) | |
| 317 int nargs; | |
| 318 register Lisp_Object *args; | |
| 319 { | |
| 320 register Lisp_Object filename_string, start, end; | |
| 321 char tempfile[20]; | |
| 322 int count = specpdl_ptr - specpdl; | |
| 323 | |
| 324 #ifdef VMS | |
| 325 strcpy (tempfile, "tmp:emacsXXXXXX."); | |
| 326 #else | |
| 327 strcpy (tempfile, "/tmp/emacsXXXXXX"); | |
| 328 #endif | |
| 329 mktemp (tempfile); | |
| 330 | |
| 331 filename_string = build_string (tempfile); | |
| 332 start = args[0]; | |
| 333 end = args[1]; | |
| 334 Fwrite_region (start, end, filename_string, Qnil, Qlambda); | |
| 335 record_unwind_protect (delete_temp_file, filename_string); | |
| 336 | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
337 if (!NILP (args[3])) |
| 296 | 338 Fdelete_region (start, end); |
| 339 | |
| 340 args[3] = filename_string; | |
| 341 Fcall_process (nargs - 2, args + 2); | |
| 342 | |
| 343 return unbind_to (count, Qnil); | |
| 344 } | |
| 345 | |
| 346 #ifndef VMS /* VMS version is in vmsproc.c. */ | |
| 347 | |
| 348 /* This is the last thing run in a newly forked inferior | |
| 349 either synchronous or asynchronous. | |
| 350 Copy descriptors IN, OUT and ERR as descriptors 0, 1 and 2. | |
| 351 Initialize inferior's priority, pgrp, connected dir and environment. | |
| 352 then exec another program based on new_argv. | |
| 353 | |
| 354 This function may change environ for the superior process. | |
| 355 Therefore, the superior process must save and restore the value | |
| 356 of environ around the vfork and the call to this function. | |
| 357 | |
| 358 ENV is the environment for the subprocess. | |
| 359 | |
| 360 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
|
361 process group. |
| 296 | 362 |
|
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
|
363 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
|
364 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
|
365 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
|
366 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
|
367 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
368 child_setup (in, out, err, new_argv, set_pgrp, current_dir) |
| 296 | 369 int in, out, err; |
| 370 register char **new_argv; | |
| 371 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
|
372 Lisp_Object current_dir; |
| 296 | 373 { |
|
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
|
374 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
|
375 |
| 296 | 376 register int pid = getpid(); |
| 377 | |
|
1201
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
378 { |
|
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
379 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
|
380 |
|
4ea86d32c012
* callproc.c (child_setup): Don't use setpriority; we just need a
Jim Blandy <jimb@redhat.com>
parents:
948
diff
changeset
|
381 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
|
382 } |
| 296 | 383 |
| 384 #ifdef subprocesses | |
| 385 /* Close Emacs's descriptors that this process should not have. */ | |
| 386 close_process_descs (); | |
| 387 #endif | |
| 388 | |
| 389 /* Note that use of alloca is always safe here. It's obvious for systems | |
| 390 that do not have true vfork or that have true (stack) alloca. | |
| 391 If using vfork and C_ALLOCA it is safe because that changes | |
| 392 the superior's static variables as if the superior had done alloca | |
| 393 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
|
394 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
395 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
|
396 register int i; |
| 296 | 397 |
|
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
|
398 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
|
399 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
|
400 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
|
401 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
|
402 temp[i] = 0; |
| 538 | 403 |
|
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
|
404 /* 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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 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
|
411 } |
| 296 | 412 |
| 413 /* Set `env' to a vector of the strings in Vprocess_environment. */ | |
| 414 { | |
| 415 register Lisp_Object tem; | |
| 416 register char **new_env; | |
| 417 register int new_length; | |
| 418 | |
| 419 new_length = 0; | |
| 420 for (tem = Vprocess_environment; | |
| 421 (XTYPE (tem) == Lisp_Cons | |
| 422 && XTYPE (XCONS (tem)->car) == Lisp_String); | |
| 423 tem = XCONS (tem)->cdr) | |
| 424 new_length++; | |
| 425 | |
| 426 /* new_length + 1 to include terminating 0 */ | |
| 427 env = new_env = (char **) alloca ((new_length + 1) * sizeof (char *)); | |
| 428 | |
|
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
|
429 /* Copy the Vprocess_alist strings into new_env. */ |
| 296 | 430 for (tem = Vprocess_environment; |
| 431 (XTYPE (tem) == Lisp_Cons | |
| 432 && XTYPE (XCONS (tem)->car) == Lisp_String); | |
| 433 tem = XCONS (tem)->cdr) | |
| 434 *new_env++ = (char *) XSTRING (XCONS (tem)->car)->data; | |
| 435 *new_env = 0; | |
| 436 } | |
| 437 | |
| 438 close (0); | |
| 439 close (1); | |
| 440 close (2); | |
| 441 | |
| 442 dup2 (in, 0); | |
| 443 dup2 (out, 1); | |
| 444 dup2 (err, 2); | |
| 445 close (in); | |
| 446 close (out); | |
| 447 close (err); | |
| 448 | |
|
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
|
449 #ifdef USG |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
450 setpgrp (); /* No arguments but equivalent in this case */ |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
451 #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
|
452 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
|
453 #endif /* USG */ |
| 296 | 454 setpgrp_of_tty (pid); |
| 455 | |
| 456 #ifdef vipc | |
| 457 something missing here; | |
| 458 #endif /* vipc */ | |
| 459 | |
| 460 /* execvp does not accept an environment arg so the only way | |
| 461 to pass this environment is to set environ. Our caller | |
| 462 is responsible for restoring the ambient value of environ. */ | |
| 463 environ = env; | |
| 464 execvp (new_argv[0], new_argv); | |
| 465 | |
| 466 write (1, "Couldn't exec the program ", 26); | |
| 467 write (1, new_argv[0], strlen (new_argv[0])); | |
| 468 _exit (1); | |
| 469 } | |
| 470 | |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
471 static int |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
472 getenv_internal (var, varlen, value, valuelen) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
473 char *var; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
474 int varlen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
475 char **value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
476 int *valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
477 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
478 Lisp_Object scan; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
479 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
480 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
|
481 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
482 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
|
483 |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
484 if (XTYPE (entry) == Lisp_String |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
485 && XSTRING (entry)->size > varlen |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
486 && XSTRING (entry)->data[varlen] == '=' |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
487 && ! bcmp (XSTRING (entry)->data, var, varlen)) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
488 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
489 *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
|
490 *valuelen = XSTRING (entry)->size - (varlen + 1); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
491 return 1; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
492 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
493 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
494 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
495 return 0; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
496 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
497 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
498 DEFUN ("getenv", Fgetenv, Sgetenv, 1, 2, 0, |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
499 "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
|
500 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
|
501 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
|
502 (var) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
503 Lisp_Object var; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
504 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
505 char *value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
506 int valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
507 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
508 CHECK_STRING (var, 0); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
509 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
|
510 &value, &valuelen)) |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
511 return make_string (value, valuelen); |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
512 else |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
513 return Qnil; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
514 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
515 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
516 /* 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
|
517 callable from C. */ |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
518 char * |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
519 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
|
520 char *var; |
|
942
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
521 { |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
522 char *value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
523 int valuelen; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
524 |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
525 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
|
526 return value; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
527 else |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
528 return 0; |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
529 } |
|
c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
Joseph Arceneaux <jla@gnu.org>
parents:
934
diff
changeset
|
530 |
| 296 | 531 #endif /* not VMS */ |
| 532 | |
| 533 init_callproc () | |
| 534 { | |
| 535 register char * sh; | |
| 536 register char **envp; | |
|
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
|
537 Lisp_Object tempdir; |
| 439 | 538 |
|
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
|
539 { |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
540 char *data_dir = egetenv ("EMACSDATA"); |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
541 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
542 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
|
543 Ffile_name_as_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
|
544 (build_string (data_dir ? data_dir : PATH_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
|
545 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
546 |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
547 /* 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
|
548 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
|
549 Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC); |
| 296 | 550 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); |
| 551 Vexec_path = nconc2 (decode_env_path ("PATH", ""), Vexec_path); | |
| 552 | |
|
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
|
553 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
|
554 if (access (XSTRING (tempdir)->data, 0) < 0) |
| 296 | 555 { |
|
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
|
556 printf ("Warning: arch-dependent data dir (%s) does not exist.\n", |
| 296 | 557 XSTRING (Vexec_directory)->data); |
| 558 sleep (2); | |
| 559 } | |
| 560 | |
|
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
|
561 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
|
562 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
|
563 { |
|
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 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
|
565 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
|
566 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
|
567 } |
|
928ed74adf4f
Restored up-to-date version of this file from pogo. What is going on
Jim Blandy <jimb@redhat.com>
parents:
942
diff
changeset
|
568 |
| 296 | 569 #ifdef VMS |
| 570 Vshell_file_name = build_string ("*dcl*"); | |
| 571 #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
|
572 sh = (char *) getenv ("SHELL"); |
| 296 | 573 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); |
| 574 #endif | |
| 575 | |
| 576 Vprocess_environment = Qnil; | |
| 577 #ifndef CANNOT_DUMP | |
| 578 if (initialized) | |
| 579 #endif | |
| 580 for (envp = environ; *envp; envp++) | |
| 581 Vprocess_environment = Fcons (build_string (*envp), | |
| 582 Vprocess_environment); | |
| 583 } | |
| 584 | |
| 585 syms_of_callproc () | |
| 586 { | |
| 587 DEFVAR_LISP ("shell-file-name", &Vshell_file_name, | |
| 588 "*File name to load inferior shells from.\n\ | |
| 589 Initialized from the SHELL environment variable."); | |
| 590 | |
| 591 DEFVAR_LISP ("exec-path", &Vexec_path, | |
| 592 "*List of directories to search programs to run in subprocesses.\n\ | |
| 593 Each element is a string (directory name) or nil (try default directory)."); | |
| 594 | |
| 595 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
|
596 "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
|
597 especially executable programs intended for Emacs to invoke."); |
| 439 | 598 |
|
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
|
599 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
|
600 "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
|
601 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
|
602 |
| 296 | 603 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
|
604 "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
|
605 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
|
606 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
|
607 when Emacs starts."); |
| 296 | 608 |
| 609 #ifndef VMS | |
| 610 defsubr (&Scall_process); | |
| 611 #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
|
612 defsubr (&Sgetenv); |
| 296 | 613 defsubr (&Scall_process_region); |
| 614 } |
