428
|
1 /* Asynchronous subprocess control for XEmacs.
|
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
|
|
3 Free Software Foundation, Inc.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
784
|
5 Copyright (C) 1995, 1996, 2001, 2002 Ben Wing.
|
428
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
814
|
24 /* This file has been Mule-ized. */
|
428
|
25
|
|
26 /* This file has been split into process.c and process-unix.c by
|
|
27 Kirill M. Katsnelson <kkm@kis.ru>, so please bash him and not
|
814
|
28 the original author(s).
|
|
29
|
|
30 Non-synch-subprocess stuff (mostly process environment) moved from
|
853
|
31 callproc.c, 4-3-02, Ben Wing.
|
|
32
|
|
33 callproc.c deleted entirely 5-23-02, Ben Wing. Good riddance!
|
|
34 */
|
428
|
35
|
|
36 #include <config.h>
|
|
37
|
814
|
38 #if defined (NO_SUBPROCESSES)
|
|
39 #error "We don't support this anymore."
|
|
40 #endif
|
428
|
41
|
|
42 #include "lisp.h"
|
|
43
|
|
44 #include "buffer.h"
|
|
45 #include "commands.h"
|
800
|
46 #include "device.h"
|
428
|
47 #include "events.h"
|
800
|
48 #include "file-coding.h"
|
428
|
49 #include "frame.h"
|
|
50 #include "hash.h"
|
|
51 #include "insdel.h"
|
|
52 #include "lstream.h"
|
|
53 #include "opaque.h"
|
|
54 #include "process.h"
|
|
55 #include "procimpl.h"
|
816
|
56 #include "sysdep.h"
|
428
|
57 #include "window.h"
|
|
58
|
|
59 #include "sysfile.h"
|
|
60 #include "sysproc.h"
|
814
|
61 #include "syssignal.h"
|
428
|
62 #include "systime.h"
|
|
63 #include "systty.h"
|
|
64 #include "syswait.h"
|
|
65
|
440
|
66 Lisp_Object Qprocessp, Qprocess_live_p;
|
428
|
67
|
|
68 /* Process methods */
|
|
69 struct process_methods the_process_methods;
|
|
70
|
|
71 /* a process object is a network connection when its pid field a cons
|
|
72 (name of name of port we are connected to . foreign host name) */
|
|
73
|
|
74 /* Valid values of process->status_symbol */
|
|
75 Lisp_Object Qrun, Qstop;
|
|
76 /* Qrun => Qopen, Qexit => Qclosed for "network connection" processes */
|
|
77 Lisp_Object Qopen, Qclosed;
|
|
78 /* Protocol families */
|
|
79 Lisp_Object Qtcp, Qudp;
|
|
80
|
|
81 #ifdef HAVE_MULTICAST
|
|
82 Lisp_Object Qmulticast; /* Will be used for occasional warnings */
|
|
83 #endif
|
|
84
|
|
85 /* t means use pty, nil means use a pipe,
|
|
86 maybe other values to come. */
|
|
87 Lisp_Object Vprocess_connection_type;
|
|
88
|
|
89 /* Read comments to DEFVAR of this */
|
|
90 int windowed_process_io;
|
|
91
|
|
92 #ifdef PROCESS_IO_BLOCKING
|
|
93 /* List of port numbers or port names to set a blocking I/O mode.
|
|
94 Nil means set a non-blocking I/O mode [default]. */
|
|
95 Lisp_Object network_stream_blocking_port_list;
|
|
96 #endif /* PROCESS_IO_BLOCKING */
|
|
97
|
|
98 /* Number of events of change of status of a process. */
|
|
99 volatile int process_tick;
|
|
100
|
|
101 /* Number of events for which the user or sentinel has been notified. */
|
|
102 static int update_tick;
|
|
103
|
|
104 /* Nonzero means delete a process right away if it exits. */
|
|
105 int delete_exited_processes;
|
|
106
|
853
|
107 /* Hash table which maps USIDs as returned by create_io_streams_cb to
|
428
|
108 process objects. Processes are not GC-protected through this! */
|
|
109 struct hash_table *usid_to_process;
|
|
110
|
|
111 /* List of process objects. */
|
|
112 Lisp_Object Vprocess_list;
|
|
113
|
442
|
114 Lisp_Object Vnull_device;
|
428
|
115
|
771
|
116 /* Cons of coding systems used to initialize process I/O on a newly-
|
|
117 created process. */
|
|
118 Lisp_Object Vdefault_process_coding_system;
|
853
|
119 /* Same for a network connection. */
|
|
120 Lisp_Object Vdefault_network_coding_system;
|
771
|
121
|
563
|
122 Lisp_Object Qprocess_error;
|
|
123 Lisp_Object Qnetwork_error;
|
|
124
|
771
|
125 Fixnum debug_process_io;
|
|
126
|
814
|
127 Lisp_Object Vshell_file_name;
|
|
128
|
|
129 /* The environment to pass to all subprocesses when they are started.
|
|
130 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... )
|
|
131 */
|
|
132 Lisp_Object Vprocess_environment;
|
|
133
|
|
134 /* Make sure egetenv() not called too soon */
|
|
135 int env_initted;
|
|
136
|
|
137 Lisp_Object Vlisp_EXEC_SUFFIXES;
|
|
138
|
428
|
139
|
|
140
|
|
141 static Lisp_Object
|
444
|
142 mark_process (Lisp_Object object)
|
428
|
143 {
|
444
|
144 Lisp_Process *process = XPROCESS (object);
|
|
145 MAYBE_PROCMETH (mark_process_data, (process));
|
|
146 mark_object (process->name);
|
|
147 mark_object (process->command);
|
|
148 mark_object (process->filter);
|
853
|
149 mark_object (process->stderr_filter);
|
444
|
150 mark_object (process->sentinel);
|
|
151 mark_object (process->buffer);
|
|
152 mark_object (process->mark);
|
853
|
153 mark_object (process->stderr_buffer);
|
|
154 mark_object (process->stderr_mark);
|
444
|
155 mark_object (process->pid);
|
|
156 mark_object (process->pipe_instream);
|
|
157 mark_object (process->pipe_outstream);
|
853
|
158 mark_object (process->pipe_errstream);
|
444
|
159 mark_object (process->coding_instream);
|
|
160 mark_object (process->coding_outstream);
|
853
|
161 mark_object (process->coding_errstream);
|
444
|
162 return process->status_symbol;
|
428
|
163 }
|
|
164
|
|
165 static void
|
444
|
166 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag)
|
428
|
167 {
|
444
|
168 Lisp_Process *process = XPROCESS (object);
|
428
|
169
|
|
170 if (print_readably)
|
563
|
171 printing_unreadable_object ("#<process %s>", XSTRING_DATA (process->name));
|
428
|
172
|
|
173 if (!escapeflag)
|
|
174 {
|
444
|
175 print_internal (process->name, printcharfun, 0);
|
428
|
176 }
|
|
177 else
|
|
178 {
|
444
|
179 int netp = network_connection_p (object);
|
826
|
180 write_c_string (printcharfun,
|
|
181 netp ? GETTEXT ("#<network connection ") :
|
|
182 GETTEXT ("#<process "));
|
444
|
183 print_internal (process->name, printcharfun, 1);
|
826
|
184 write_c_string (printcharfun, (netp ? " " : " pid "));
|
444
|
185 print_internal (process->pid, printcharfun, 1);
|
800
|
186 write_fmt_string_lisp (printcharfun, " state:%S", 1, process->status_symbol);
|
444
|
187 MAYBE_PROCMETH (print_process_data, (process, printcharfun));
|
826
|
188 write_c_string (printcharfun, ">");
|
428
|
189 }
|
|
190 }
|
|
191
|
|
192 #ifdef HAVE_WINDOW_SYSTEM
|
440
|
193 extern void debug_process_finalization (Lisp_Process *p);
|
428
|
194 #endif /* HAVE_WINDOW_SYSTEM */
|
|
195
|
|
196 static void
|
|
197 finalize_process (void *header, int for_disksave)
|
|
198 {
|
|
199 /* #### this probably needs to be tied into the tty event loop */
|
|
200 /* #### when there is one */
|
440
|
201 Lisp_Process *p = (Lisp_Process *) header;
|
428
|
202 #ifdef HAVE_WINDOW_SYSTEM
|
|
203 if (!for_disksave)
|
|
204 {
|
|
205 debug_process_finalization (p);
|
|
206 }
|
|
207 #endif /* HAVE_WINDOW_SYSTEM */
|
|
208
|
|
209 if (p->process_data)
|
|
210 {
|
|
211 MAYBE_PROCMETH (finalize_process_data, (p, for_disksave));
|
|
212 if (!for_disksave)
|
|
213 xfree (p->process_data);
|
|
214 }
|
|
215 }
|
|
216
|
|
217 DEFINE_LRECORD_IMPLEMENTATION ("process", process,
|
|
218 mark_process, print_process, finalize_process,
|
440
|
219 0, 0, 0, Lisp_Process);
|
428
|
220
|
|
221 /************************************************************************/
|
|
222 /* basic process accessors */
|
|
223 /************************************************************************/
|
|
224
|
771
|
225 /* This function returns low-level streams, connected directly to the child
|
|
226 process, rather than en/decoding streams */
|
428
|
227 void
|
853
|
228 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr,
|
|
229 Lisp_Object *errstr)
|
428
|
230 {
|
|
231 assert (p);
|
853
|
232 assert (NILP (p->pipe_instream) || LSTREAMP (p->pipe_instream));
|
|
233 assert (NILP (p->pipe_outstream) || LSTREAMP (p->pipe_outstream));
|
|
234 assert (NILP (p->pipe_errstream) || LSTREAMP (p->pipe_errstream));
|
428
|
235 *instr = p->pipe_instream;
|
|
236 *outstr = p->pipe_outstream;
|
853
|
237 *errstr = p->pipe_errstream;
|
428
|
238 }
|
|
239
|
853
|
240 /* Given a USID referring to either a process's instream or errstream,
|
|
241 return the associated process. */
|
440
|
242 Lisp_Process *
|
428
|
243 get_process_from_usid (USID usid)
|
|
244 {
|
442
|
245 const void *vval;
|
428
|
246
|
|
247 assert (usid != USID_ERROR && usid != USID_DONTHASH);
|
|
248
|
442
|
249 if (gethash ((const void*)usid, usid_to_process, &vval))
|
428
|
250 {
|
444
|
251 Lisp_Object process;
|
826
|
252 process = VOID_TO_LISP (vval);
|
444
|
253 return XPROCESS (process);
|
428
|
254 }
|
|
255 else
|
|
256 return 0;
|
|
257 }
|
|
258
|
|
259 int
|
853
|
260 get_process_selected_p (Lisp_Process *p, int do_err)
|
428
|
261 {
|
853
|
262 return do_err ? p->err_selected : p->in_selected;
|
428
|
263 }
|
|
264
|
|
265 void
|
853
|
266 set_process_selected_p (Lisp_Process *p, int in_selected, int err_selected)
|
428
|
267 {
|
853
|
268 p->in_selected = !!in_selected;
|
|
269 p->err_selected = !!err_selected;
|
428
|
270 }
|
|
271
|
|
272 int
|
440
|
273 connected_via_filedesc_p (Lisp_Process *p)
|
428
|
274 {
|
|
275 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p));
|
|
276 }
|
|
277
|
|
278 #ifdef HAVE_SOCKETS
|
|
279 int
|
|
280 network_connection_p (Lisp_Object process)
|
|
281 {
|
|
282 return CONSP (XPROCESS (process)->pid);
|
|
283 }
|
|
284 #endif
|
|
285
|
|
286 DEFUN ("processp", Fprocessp, 1, 1, 0, /*
|
|
287 Return t if OBJECT is a process.
|
|
288 */
|
444
|
289 (object))
|
428
|
290 {
|
444
|
291 return PROCESSP (object) ? Qt : Qnil;
|
428
|
292 }
|
|
293
|
440
|
294 DEFUN ("process-live-p", Fprocess_live_p, 1, 1, 0, /*
|
|
295 Return t if OBJECT is a process that is alive.
|
|
296 */
|
444
|
297 (object))
|
440
|
298 {
|
444
|
299 return PROCESSP (object) && PROCESS_LIVE_P (XPROCESS (object))
|
|
300 ? Qt : Qnil;
|
440
|
301 }
|
|
302
|
428
|
303 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /*
|
|
304 Return a list of all processes.
|
|
305 */
|
|
306 ())
|
|
307 {
|
|
308 return Fcopy_sequence (Vprocess_list);
|
|
309 }
|
|
310
|
|
311 DEFUN ("get-process", Fget_process, 1, 1, 0, /*
|
444
|
312 Return the process named PROCESS-NAME (a string), or nil if there is none.
|
|
313 PROCESS-NAME may also be a process; if so, the value is that process.
|
428
|
314 */
|
444
|
315 (process_name))
|
428
|
316 {
|
444
|
317 if (PROCESSP (process_name))
|
|
318 return process_name;
|
428
|
319
|
|
320 if (!gc_in_progress)
|
|
321 /* this only gets called during GC when emacs is going away as a result
|
|
322 of a signal or crash. */
|
444
|
323 CHECK_STRING (process_name);
|
428
|
324
|
444
|
325 {
|
|
326 LIST_LOOP_2 (process, Vprocess_list)
|
|
327 if (internal_equal (process_name, XPROCESS (process)->name, 0))
|
|
328 return process;
|
|
329 }
|
428
|
330 return Qnil;
|
|
331 }
|
|
332
|
|
333 DEFUN ("get-buffer-process", Fget_buffer_process, 1, 1, 0, /*
|
|
334 Return the (or, a) process associated with BUFFER.
|
|
335 BUFFER may be a buffer or the name of one.
|
|
336 */
|
444
|
337 (buffer))
|
428
|
338 {
|
444
|
339 if (NILP (buffer)) return Qnil;
|
|
340 buffer = Fget_buffer (buffer);
|
|
341 if (NILP (buffer)) return Qnil;
|
428
|
342
|
444
|
343 {
|
|
344 LIST_LOOP_2 (process, Vprocess_list)
|
|
345 if (EQ (XPROCESS (process)->buffer, buffer))
|
|
346 return process;
|
|
347 }
|
428
|
348 return Qnil;
|
|
349 }
|
|
350
|
|
351 /* This is how commands for the user decode process arguments. It
|
|
352 accepts a process, a process name, a buffer, a buffer name, or nil.
|
|
353 Buffers denote the first process in the buffer, and nil denotes the
|
|
354 current buffer. */
|
|
355
|
|
356 static Lisp_Object
|
|
357 get_process (Lisp_Object name)
|
|
358 {
|
444
|
359 Lisp_Object buffer;
|
428
|
360
|
|
361 #ifdef I18N3
|
|
362 /* #### Look more closely into translating process names. */
|
|
363 #endif
|
|
364
|
|
365 /* This may be called during a GC from process_send_signal() from
|
|
366 kill_buffer_processes() if emacs decides to abort(). */
|
|
367 if (PROCESSP (name))
|
|
368 return name;
|
444
|
369 else if (STRINGP (name))
|
428
|
370 {
|
444
|
371 Lisp_Object object = Fget_process (name);
|
|
372 if (PROCESSP (object))
|
|
373 return object;
|
|
374
|
|
375 buffer = Fget_buffer (name);
|
|
376 if (BUFFERP (buffer))
|
|
377 goto have_buffer_object;
|
|
378
|
563
|
379 invalid_argument ("Process does not exist", name);
|
428
|
380 }
|
|
381 else if (NILP (name))
|
444
|
382 {
|
|
383 buffer = Fcurrent_buffer ();
|
|
384 goto have_buffer_object;
|
|
385 }
|
|
386 else if (BUFFERP (name))
|
|
387 {
|
|
388 Lisp_Object process;
|
|
389 buffer = name;
|
428
|
390
|
444
|
391 have_buffer_object:
|
|
392 process = Fget_buffer_process (buffer);
|
|
393 if (PROCESSP (process))
|
|
394 return process;
|
|
395
|
563
|
396 invalid_argument ("Buffer has no process", buffer);
|
428
|
397 }
|
|
398 else
|
444
|
399 return get_process (Fsignal (Qwrong_type_argument,
|
771
|
400 (list2 (build_msg_string ("process or buffer or nil"),
|
444
|
401 name))));
|
428
|
402 }
|
|
403
|
|
404 DEFUN ("process-id", Fprocess_id, 1, 1, 0, /*
|
|
405 Return the process id of PROCESS.
|
|
406 This is the pid of the Unix process which PROCESS uses or talks to.
|
|
407 For a network connection, this value is a cons of
|
|
408 (foreign-network-port . foreign-host-name).
|
|
409 */
|
444
|
410 (process))
|
428
|
411 {
|
|
412 Lisp_Object pid;
|
444
|
413 CHECK_PROCESS (process);
|
428
|
414
|
444
|
415 pid = XPROCESS (process)->pid;
|
|
416 if (network_connection_p (process))
|
428
|
417 /* return Qnil; */
|
|
418 return Fcons (Fcar (pid), Fcdr (pid));
|
|
419 else
|
|
420 return pid;
|
|
421 }
|
|
422
|
|
423 DEFUN ("process-name", Fprocess_name, 1, 1, 0, /*
|
|
424 Return the name of PROCESS, as a string.
|
|
425 This is the name of the program invoked in PROCESS,
|
|
426 possibly modified to make it unique among process names.
|
|
427 */
|
444
|
428 (process))
|
428
|
429 {
|
444
|
430 CHECK_PROCESS (process);
|
|
431 return XPROCESS (process)->name;
|
428
|
432 }
|
|
433
|
|
434 DEFUN ("process-command", Fprocess_command, 1, 1, 0, /*
|
|
435 Return the command that was executed to start PROCESS.
|
|
436 This is a list of strings, the first string being the program executed
|
|
437 and the rest of the strings being the arguments given to it.
|
|
438 */
|
444
|
439 (process))
|
428
|
440 {
|
444
|
441 CHECK_PROCESS (process);
|
|
442 return XPROCESS (process)->command;
|
428
|
443 }
|
|
444
|
|
445
|
|
446 /************************************************************************/
|
|
447 /* creating a process */
|
|
448 /************************************************************************/
|
|
449
|
563
|
450 DOESNT_RETURN
|
|
451 report_process_error (const char *string, Lisp_Object data)
|
|
452 {
|
|
453 report_error_with_errno (Qprocess_error, string, data);
|
|
454 }
|
|
455
|
|
456 DOESNT_RETURN
|
|
457 report_network_error (const char *string, Lisp_Object data)
|
|
458 {
|
|
459 report_error_with_errno (Qnetwork_error, string, data);
|
|
460 }
|
|
461
|
428
|
462 Lisp_Object
|
|
463 make_process_internal (Lisp_Object name)
|
|
464 {
|
|
465 Lisp_Object val, name1;
|
|
466 int i;
|
440
|
467 Lisp_Process *p = alloc_lcrecord_type (Lisp_Process, &lrecord_process);
|
428
|
468
|
|
469 /* If name is already in use, modify it until it is unused. */
|
|
470 name1 = name;
|
|
471 for (i = 1; ; i++)
|
|
472 {
|
|
473 char suffix[10];
|
|
474 Lisp_Object tem = Fget_process (name1);
|
|
475 if (NILP (tem))
|
|
476 break;
|
|
477 sprintf (suffix, "<%d>", i);
|
|
478 name1 = concat2 (name, build_string (suffix));
|
|
479 }
|
|
480 name = name1;
|
|
481 p->name = name;
|
|
482
|
|
483 p->command = Qnil;
|
|
484 p->filter = Qnil;
|
853
|
485 p->stderr_filter = Qnil;
|
428
|
486 p->sentinel = Qnil;
|
|
487 p->buffer = Qnil;
|
|
488 p->mark = Fmake_marker ();
|
853
|
489 p->stderr_buffer = Qnil;
|
|
490 p->stderr_mark = Fmake_marker ();
|
428
|
491 p->pid = Qnil;
|
|
492 p->status_symbol = Qrun;
|
|
493 p->exit_code = 0;
|
|
494 p->core_dumped = 0;
|
|
495 p->filter_does_read = 0;
|
|
496 p->kill_without_query = 0;
|
853
|
497 p->separate_stderr = 0;
|
|
498 p->in_selected = 0;
|
|
499 p->err_selected = 0;
|
428
|
500 p->tick = 0;
|
|
501 p->update_tick = 0;
|
|
502 p->pipe_instream = Qnil;
|
|
503 p->pipe_outstream = Qnil;
|
853
|
504 p->pipe_errstream = Qnil;
|
428
|
505 p->coding_instream = Qnil;
|
|
506 p->coding_outstream = Qnil;
|
853
|
507 p->coding_errstream = Qnil;
|
428
|
508
|
|
509 p->process_data = 0;
|
|
510 MAYBE_PROCMETH (alloc_process_data, (p));
|
|
511
|
793
|
512 val = wrap_process (p);
|
428
|
513
|
|
514 Vprocess_list = Fcons (val, Vprocess_list);
|
|
515 return val;
|
|
516 }
|
|
517
|
|
518 void
|
853
|
519 init_process_io_handles (Lisp_Process *p, void* in, void* out, void* err,
|
|
520 int flags)
|
428
|
521 {
|
853
|
522 USID in_usid, err_usid;
|
771
|
523 Lisp_Object incode, outcode;
|
|
524
|
853
|
525 if (flags & STREAM_NETWORK_CONNECTION)
|
|
526 {
|
|
527 if (!CONSP (Vdefault_network_coding_system) ||
|
|
528 NILP (incode = (find_coding_system_for_text_file
|
|
529 (Fcar (Vdefault_network_coding_system), 1))) ||
|
|
530 NILP (outcode = (find_coding_system_for_text_file
|
|
531 (Fcdr (Vdefault_network_coding_system), 0))))
|
|
532 signal_error (Qinvalid_state,
|
|
533 "Bogus value for `default-network-coding-system'",
|
|
534 Vdefault_network_coding_system);
|
|
535 }
|
|
536 else
|
|
537 {
|
|
538 if (!CONSP (Vdefault_process_coding_system) ||
|
|
539 NILP (incode = (find_coding_system_for_text_file
|
|
540 (Fcar (Vdefault_process_coding_system), 1))) ||
|
|
541 NILP (outcode = (find_coding_system_for_text_file
|
|
542 (Fcdr (Vdefault_process_coding_system), 0))))
|
|
543 signal_error (Qinvalid_state,
|
|
544 "Bogus value for `default-process-coding-system'",
|
|
545 Vdefault_process_coding_system);
|
|
546 }
|
771
|
547
|
784
|
548 if (!NILP (Vcoding_system_for_read) &&
|
|
549 NILP (incode = (find_coding_system_for_text_file
|
|
550 (Vcoding_system_for_read, 1))))
|
|
551 signal_error (Qinvalid_state,
|
|
552 "Bogus value for `coding-system-for-read'",
|
|
553 Vcoding_system_for_read);
|
|
554
|
|
555 if (!NILP (Vcoding_system_for_write) &&
|
|
556 NILP (outcode = (find_coding_system_for_text_file
|
|
557 (Vcoding_system_for_write, 0))))
|
|
558 signal_error (Qinvalid_state,
|
|
559 "Bogus value for `coding-system-for-write'",
|
|
560 Vcoding_system_for_write);
|
|
561
|
853
|
562 event_stream_create_io_streams (in, out, err,
|
|
563 &p->pipe_instream,
|
|
564 &p->pipe_outstream,
|
|
565 &p->pipe_errstream,
|
|
566 &in_usid, &err_usid,
|
|
567 flags);
|
428
|
568
|
853
|
569 if (in_usid == USID_ERROR || err_usid == USID_ERROR)
|
563
|
570 signal_error (Qprocess_error, "Setting up communication with subprocess",
|
853
|
571 wrap_process (p));
|
428
|
572
|
853
|
573 if (in_usid != USID_DONTHASH)
|
428
|
574 {
|
444
|
575 Lisp_Object process = Qnil;
|
793
|
576 process = wrap_process (p);
|
853
|
577 puthash ((const void*) in_usid, LISP_TO_VOID (process), usid_to_process);
|
428
|
578 }
|
|
579
|
853
|
580 if (err_usid != USID_DONTHASH)
|
|
581 {
|
|
582 Lisp_Object process = Qnil;
|
|
583 process = wrap_process (p);
|
|
584 puthash ((const void*) err_usid, LISP_TO_VOID (process),
|
|
585 usid_to_process);
|
|
586 }
|
|
587
|
|
588 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, err, flags));
|
428
|
589
|
771
|
590 p->coding_instream =
|
800
|
591 make_coding_input_stream (XLSTREAM (p->pipe_instream), incode,
|
|
592 CODING_DECODE, 0);
|
853
|
593 if (!NILP (p->pipe_errstream))
|
|
594 p->coding_errstream =
|
|
595 make_coding_input_stream
|
|
596 (XLSTREAM (p->pipe_errstream), incode, CODING_DECODE, 0);
|
771
|
597 p->coding_outstream =
|
800
|
598 make_coding_output_stream (XLSTREAM (p->pipe_outstream), outcode,
|
|
599 CODING_ENCODE, 0);
|
428
|
600 }
|
|
601
|
|
602 static void
|
|
603 create_process (Lisp_Object process, Lisp_Object *argv, int nargv,
|
853
|
604 Lisp_Object program, Lisp_Object cur_dir,
|
|
605 int separate_err)
|
428
|
606 {
|
440
|
607 Lisp_Process *p = XPROCESS (process);
|
428
|
608 int pid;
|
|
609
|
|
610 /* *_create_process may change status_symbol, if the process
|
|
611 is a kind of "fire-and-forget" (no I/O, unwaitable) */
|
|
612 p->status_symbol = Qrun;
|
|
613 p->exit_code = 0;
|
|
614
|
853
|
615 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir,
|
|
616 separate_err));
|
428
|
617
|
|
618 p->pid = make_int (pid);
|
440
|
619 if (PROCESS_LIVE_P (p))
|
853
|
620 event_stream_select_process (p, 1, 1);
|
428
|
621 }
|
|
622
|
|
623 /* This function is the unwind_protect form for Fstart_process_internal. If
|
444
|
624 PROCESS doesn't have its pid set, then we know someone has signalled
|
428
|
625 an error and the process wasn't started successfully, so we should
|
|
626 remove it from the process list. */
|
444
|
627 static void remove_process (Lisp_Object process);
|
428
|
628 static Lisp_Object
|
444
|
629 start_process_unwind (Lisp_Object process)
|
428
|
630 {
|
444
|
631 /* Was PROCESS started successfully? */
|
|
632 if (EQ (XPROCESS (process)->pid, Qnil))
|
|
633 remove_process (process);
|
428
|
634 return Qnil;
|
|
635 }
|
|
636
|
|
637 DEFUN ("start-process-internal", Fstart_process_internal, 3, MANY, 0, /*
|
853
|
638 Internal function to start a program in a subprocess.
|
|
639 Lisp callers should use `start-process' instead.
|
|
640
|
|
641 Returns the process object for it.
|
428
|
642 Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS
|
|
643 NAME is name for process. It is modified if necessary to make it unique.
|
|
644 BUFFER is the buffer or (buffer-name) to associate with the process.
|
|
645 Process output goes at end of that buffer, unless you specify
|
|
646 an output stream or filter function to handle the output.
|
|
647 BUFFER may be also nil, meaning that this process is not associated
|
853
|
648 with any buffer.
|
|
649 BUFFER can also have the form (REAL-BUFFER STDERR-BUFFER); in that case,
|
|
650 REAL-BUFFER says what to do with standard output, as above,
|
|
651 while STDERR-BUFFER says what to do with standard error in the child.
|
|
652 STDERR-BUFFER may be nil (discard standard error output, unless a stderr
|
|
653 filter is set). Note that if you do not use this form at process creation,
|
|
654 stdout and stderr will be mixed in the output buffer, and this cannot be
|
|
655 changed, even by setting a stderr filter.
|
428
|
656 Third arg is program file name. It is searched for as in the shell.
|
|
657 Remaining arguments are strings to give program as arguments.
|
853
|
658
|
|
659 Read and write coding systems for the process are determined from
|
|
660 `coding-system-for-read' and `coding-system-for-write' (intended as
|
|
661 overriding coding systems to be *bound* by Lisp code, not set), or
|
|
662 from `default-process-coding-system' if either or both are nil. You can
|
|
663 change the coding systems later on using `set-process-coding-system',
|
|
664 `set-process-input-coding-system', or `set-process-output-coding-system'.
|
|
665
|
|
666 See also `set-process-filter' and `set-process-stderr-filter'.
|
428
|
667 */
|
|
668 (int nargs, Lisp_Object *args))
|
|
669 {
|
|
670 /* This function can call lisp */
|
853
|
671 Lisp_Object buffer, stderr_buffer, name, program, process, current_dir;
|
|
672 int separate_stderr;
|
428
|
673 Lisp_Object tem;
|
|
674 int speccount = specpdl_depth ();
|
|
675 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
676
|
|
677 name = args[0];
|
|
678 buffer = args[1];
|
|
679 program = args[2];
|
|
680 current_dir = Qnil;
|
|
681
|
|
682 /* Protect against various file handlers doing GCs below. */
|
|
683 GCPRO3 (buffer, program, current_dir);
|
|
684
|
853
|
685 if (CONSP (buffer))
|
|
686 {
|
|
687 if (!CONSP (XCDR (buffer)))
|
|
688 invalid_argument ("Invalid BUFFER argument to `start-process'",
|
|
689 buffer);
|
|
690 if (!NILP (XCDR (XCDR (buffer))))
|
|
691 invalid_argument ("Invalid BUFFER argument to `start-process'",
|
|
692 buffer);
|
|
693 stderr_buffer = XCAR (XCDR (buffer));
|
|
694 buffer = XCAR (buffer);
|
|
695 separate_stderr = 1;
|
|
696 }
|
|
697 else
|
|
698 {
|
|
699 stderr_buffer = Qnil;
|
|
700 separate_stderr = 0;
|
|
701 }
|
|
702
|
428
|
703 if (!NILP (buffer))
|
|
704 buffer = Fget_buffer_create (buffer);
|
853
|
705 if (!NILP (stderr_buffer))
|
|
706 stderr_buffer = Fget_buffer_create (stderr_buffer);
|
428
|
707
|
|
708 CHECK_STRING (name);
|
|
709 CHECK_STRING (program);
|
|
710
|
|
711 /* Make sure that the child will be able to chdir to the current
|
502
|
712 buffer's current directory, or its unhandled equivalent. [[ We
|
428
|
713 can't just have the child check for an error when it does the
|
502
|
714 chdir, since it's in a vfork. ]] -- not any more, we don't use
|
|
715 vfork. -ben
|
428
|
716
|
502
|
717 Note: These calls are spread out to insure that the return values
|
|
718 of the calls (which may be newly-created strings) are properly
|
|
719 GC-protected. */
|
428
|
720 current_dir = current_buffer->directory;
|
502
|
721 /* If the current dir has no terminating slash, we'll get undesirable
|
|
722 results, so put the slash back. */
|
|
723 current_dir = Ffile_name_as_directory (current_dir);
|
428
|
724 current_dir = Funhandled_file_name_directory (current_dir);
|
|
725 current_dir = expand_and_dir_to_file (current_dir, Qnil);
|
|
726
|
|
727 #if 0 /* This loser breaks ange-ftp */
|
|
728 /* dmoore - if you re-enable this code, you have to gcprotect
|
|
729 current_buffer through the above calls. */
|
|
730 if (NILP (Ffile_accessible_directory_p (current_dir)))
|
563
|
731 signal_error (Qprocess_error, "Setting current directory",
|
|
732 current_buffer->directory);
|
428
|
733 #endif /* 0 */
|
|
734
|
|
735 /* If program file name is not absolute, search our path for it */
|
826
|
736 if (!IS_DIRECTORY_SEP (string_byte (program, 0))
|
428
|
737 && !(XSTRING_LENGTH (program) > 1
|
826
|
738 && IS_DEVICE_SEP (string_byte (program, 1))))
|
428
|
739 {
|
|
740 struct gcpro ngcpro1;
|
|
741
|
|
742 tem = Qnil;
|
|
743 NGCPRO1 (tem);
|
|
744 locate_file (Vexec_path, program, Vlisp_EXEC_SUFFIXES, &tem, X_OK);
|
|
745 if (NILP (tem))
|
563
|
746 signal_error (Qprocess_error, "Searching for program", program);
|
428
|
747 program = Fexpand_file_name (tem, Qnil);
|
|
748 NUNGCPRO;
|
|
749 }
|
|
750 else
|
|
751 {
|
442
|
752 /* we still need to canonicalize it and ensure it has the proper
|
|
753 ending, e.g. .exe */
|
|
754 struct gcpro ngcpro1;
|
|
755
|
|
756 tem = Qnil;
|
|
757 NGCPRO1 (tem);
|
|
758 locate_file (list1 (build_string ("")), program, Vlisp_EXEC_SUFFIXES,
|
|
759 &tem, X_OK);
|
|
760 if (NILP (tem))
|
563
|
761 signal_error (Qprocess_error, "Searching for program", program);
|
442
|
762 program = tem;
|
|
763 NUNGCPRO;
|
428
|
764 }
|
|
765
|
442
|
766 if (!NILP (Ffile_directory_p (program)))
|
|
767 invalid_operation ("Specified program for new process is a directory",
|
|
768 program);
|
|
769
|
444
|
770 process = make_process_internal (name);
|
428
|
771
|
444
|
772 XPROCESS (process)->buffer = buffer;
|
853
|
773 XPROCESS (process)->stderr_buffer = stderr_buffer;
|
|
774 XPROCESS (process)->separate_stderr = separate_stderr;
|
814
|
775 XPROCESS (process)->command = Flist (nargs - 2, args + 2);
|
428
|
776
|
|
777 /* Make the process marker point into the process buffer (if any). */
|
|
778 if (!NILP (buffer))
|
444
|
779 Fset_marker (XPROCESS (process)->mark,
|
428
|
780 make_int (BUF_ZV (XBUFFER (buffer))), buffer);
|
853
|
781 if (!NILP (stderr_buffer))
|
|
782 Fset_marker (XPROCESS (process)->stderr_mark,
|
|
783 make_int (BUF_ZV (XBUFFER (stderr_buffer))), stderr_buffer);
|
428
|
784
|
|
785 /* If an error occurs and we can't start the process, we want to
|
|
786 remove it from the process list. This means that each error
|
|
787 check in create_process doesn't need to call remove_process
|
|
788 itself; it's all taken care of here. */
|
444
|
789 record_unwind_protect (start_process_unwind, process);
|
428
|
790
|
853
|
791 create_process (process, args + 3, nargs - 3, program, current_dir,
|
|
792 separate_stderr);
|
428
|
793
|
|
794 UNGCPRO;
|
771
|
795 return unbind_to_1 (speccount, process);
|
428
|
796 }
|
|
797
|
|
798
|
|
799 #ifdef HAVE_SOCKETS
|
|
800
|
|
801
|
|
802 /* #### The network support is fairly synthetical. What we actually
|
|
803 need is a single function, which supports all datagram, stream and
|
|
804 packet stream connections, arbitrary protocol families should they
|
|
805 be supported by the target system, multicast groups, in both data
|
|
806 and control rooted/nonrooted flavors, service quality etc whatever
|
|
807 is supported by the underlying network.
|
|
808
|
|
809 It must accept a property list describing the connection. The current
|
|
810 functions must then go to lisp and provide a suitable list for the
|
|
811 generalized connection function.
|
|
812
|
|
813 Both UNIX and Win32 support BSD sockets, and there are many extensions
|
|
814 available (Sockets 2 spec).
|
|
815
|
|
816 A todo is define a consistent set of properties abstracting a
|
|
817 network connection. -kkm
|
|
818 */
|
|
819
|
|
820
|
|
821 /* open a TCP network connection to a given HOST/SERVICE. Treated
|
|
822 exactly like a normal process when reading and writing. Only
|
|
823 differences are in status display and process deletion. A network
|
|
824 connection has no PID; you cannot signal it. All you can do is
|
|
825 deactivate and close it via delete-process */
|
|
826
|
442
|
827 DEFUN ("open-network-stream-internal", Fopen_network_stream_internal, 4, 5,
|
|
828 0, /*
|
428
|
829 Open a TCP connection for a service to a host.
|
444
|
830 Return a process object to represent the connection.
|
428
|
831 Input and output work as for subprocesses; `delete-process' closes it.
|
|
832
|
|
833 NAME is name for process. It is modified if necessary to make it unique.
|
|
834 BUFFER is the buffer (or buffer-name) to associate with the process.
|
|
835 Process output goes at end of that buffer, unless you specify
|
|
836 an output stream or filter function to handle the output.
|
|
837 BUFFER may also be nil, meaning that this process is not associated
|
|
838 with any buffer.
|
444
|
839 Third arg HOST (a string) is the name of the host to connect to,
|
|
840 or its IP address.
|
|
841 Fourth arg SERVICE is the name of the service desired (a string),
|
|
842 or an integer specifying a port number to connect to.
|
|
843 Optional fifth arg PROTOCOL is a network protocol. Currently only 'tcp
|
428
|
844 (Transmission Control Protocol) and 'udp (User Datagram Protocol) are
|
|
845 supported. When omitted, 'tcp is assumed.
|
|
846
|
442
|
847 Output via `process-send-string' and input via buffer or filter (see
|
428
|
848 `set-process-filter') are stream-oriented. That means UDP datagrams are
|
|
849 not guaranteed to be sent and received in discrete packets. (But small
|
|
850 datagrams around 500 bytes that are not truncated by `process-send-string'
|
444
|
851 are usually fine.) Note further that the UDP protocol does not guard
|
|
852 against lost packets.
|
428
|
853 */
|
|
854 (name, buffer, host, service, protocol))
|
|
855 {
|
|
856 /* This function can GC */
|
444
|
857 Lisp_Object process = Qnil;
|
428
|
858 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1;
|
|
859 void *inch, *outch;
|
|
860
|
|
861 GCPRO5 (name, buffer, host, service, protocol);
|
|
862 CHECK_STRING (name);
|
|
863
|
771
|
864 if (NILP (protocol))
|
428
|
865 protocol = Qtcp;
|
|
866 else
|
|
867 CHECK_SYMBOL (protocol);
|
|
868
|
|
869 /* Since this code is inside HAVE_SOCKETS, existence of
|
|
870 open_network_stream is mandatory */
|
|
871 PROCMETH (open_network_stream, (name, host, service, protocol,
|
|
872 &inch, &outch));
|
|
873
|
|
874 if (!NILP (buffer))
|
|
875 buffer = Fget_buffer_create (buffer);
|
444
|
876 process = make_process_internal (name);
|
|
877 NGCPRO1 (process);
|
428
|
878
|
444
|
879 XPROCESS (process)->pid = Fcons (service, host);
|
|
880 XPROCESS (process)->buffer = buffer;
|
771
|
881 init_process_io_handles (XPROCESS (process), (void *) inch, (void *) outch,
|
853
|
882 (void *) -1,
|
428
|
883 STREAM_NETWORK_CONNECTION);
|
|
884
|
853
|
885 event_stream_select_process (XPROCESS (process), 1, 1);
|
428
|
886
|
|
887 UNGCPRO;
|
|
888 NUNGCPRO;
|
444
|
889 return process;
|
428
|
890 }
|
|
891
|
|
892 #ifdef HAVE_MULTICAST
|
|
893
|
|
894 DEFUN ("open-multicast-group-internal", Fopen_multicast_group_internal, 5, 5, 0, /*
|
|
895 Open a multicast connection on the specified dest/port/ttl.
|
444
|
896 Return a process object to represent the connection.
|
428
|
897 Input and output work as for subprocesses; `delete-process' closes it.
|
|
898
|
|
899 NAME is name for process. It is modified if necessary to make it unique.
|
|
900 BUFFER is the buffer (or buffer-name) to associate with the process.
|
|
901 Process output goes at end of that buffer, unless you specify
|
|
902 an output stream or filter function to handle the output.
|
|
903 BUFFER may also be nil, meaning that this process is not associated
|
|
904 with any buffer.
|
|
905 Third, fourth and fifth args are the multicast destination group, port and ttl.
|
|
906 dest must be an internet address between 224.0.0.0 and 239.255.255.255
|
|
907 port is a communication port like in traditional unicast
|
|
908 ttl is the time-to-live (15 for site, 63 for region and 127 for world)
|
|
909 */
|
|
910 (name, buffer, dest, port, ttl))
|
|
911 {
|
|
912 /* This function can GC */
|
444
|
913 Lisp_Object process = Qnil;
|
428
|
914 struct gcpro gcpro1;
|
|
915 void *inch, *outch;
|
|
916
|
|
917 CHECK_STRING (name);
|
|
918
|
|
919 /* Since this code is inside HAVE_MULTICAST, existence of
|
771
|
920 open_multicast_group is mandatory */
|
428
|
921 PROCMETH (open_multicast_group, (name, dest, port, ttl,
|
|
922 &inch, &outch));
|
|
923
|
|
924 if (!NILP (buffer))
|
|
925 buffer = Fget_buffer_create (buffer);
|
|
926
|
444
|
927 process = make_process_internal (name);
|
|
928 GCPRO1 (process);
|
428
|
929
|
444
|
930 XPROCESS (process)->pid = Fcons (port, dest);
|
|
931 XPROCESS (process)->buffer = buffer;
|
853
|
932 init_process_io_handles (XPROCESS (process), (void *) inch, (void *) outch,
|
|
933 (void *) -1,
|
428
|
934 STREAM_NETWORK_CONNECTION);
|
|
935
|
853
|
936 event_stream_select_process (XPROCESS (process), 1, 1);
|
428
|
937
|
|
938 UNGCPRO;
|
444
|
939 return process;
|
428
|
940 }
|
|
941 #endif /* HAVE_MULTICAST */
|
|
942
|
|
943 #endif /* HAVE_SOCKETS */
|
|
944
|
|
945 Lisp_Object
|
|
946 canonicalize_host_name (Lisp_Object host)
|
|
947 {
|
|
948 return PROCMETH_OR_GIVEN (canonicalize_host_name, (host), host);
|
|
949 }
|
|
950
|
|
951
|
|
952 DEFUN ("set-process-window-size", Fset_process_window_size, 3, 3, 0, /*
|
|
953 Tell PROCESS that it has logical window size HEIGHT and WIDTH.
|
|
954 */
|
444
|
955 (process, height, width))
|
428
|
956 {
|
444
|
957 CHECK_PROCESS (process);
|
428
|
958 CHECK_NATNUM (height);
|
|
959 CHECK_NATNUM (width);
|
|
960 return
|
444
|
961 MAYBE_INT_PROCMETH (set_window_size,
|
|
962 (XPROCESS (process), XINT (height), XINT (width))) <= 0
|
428
|
963 ? Qnil : Qt;
|
|
964 }
|
|
965
|
|
966
|
|
967 /************************************************************************/
|
|
968 /* Process I/O */
|
|
969 /************************************************************************/
|
|
970
|
844
|
971 /* Set up PROCESS's buffer for insertion of process data at PROCESS's
|
|
972 mark.
|
|
973
|
|
974 Sets the current buffer to PROCESS's buffer, inhibits read only,
|
|
975 remembers current point, sets point to PROCESS'S mark, widens if
|
|
976 necessary.
|
|
977 */
|
|
978 static int
|
853
|
979 process_setup_for_insertion (Lisp_Object process, int read_stderr)
|
844
|
980 {
|
|
981 Lisp_Process *p = XPROCESS (process);
|
|
982 int spec = specpdl_depth ();
|
853
|
983 Lisp_Object buffer = read_stderr ? p->stderr_buffer : p->buffer;
|
|
984 Lisp_Object mark = read_stderr ? p->stderr_mark : p->mark;
|
|
985 struct buffer *buf = XBUFFER (buffer);
|
844
|
986 Charbpos output_pt;
|
|
987
|
|
988 if (buf != current_buffer)
|
|
989 {
|
|
990 record_unwind_protect (save_current_buffer_restore,
|
|
991 Fcurrent_buffer ());
|
|
992 set_buffer_internal (buf);
|
|
993 }
|
|
994
|
|
995 record_unwind_protect (save_excursion_restore, save_excursion_save ());
|
|
996 specbind (Qinhibit_read_only, Qt);
|
|
997
|
|
998 /* Insert new output into buffer
|
|
999 at the current end-of-output marker,
|
|
1000 thus preserving logical ordering of input and output. */
|
853
|
1001 if (XMARKER (mark)->buffer)
|
|
1002 output_pt = marker_position (mark);
|
844
|
1003 else
|
|
1004 output_pt = BUF_ZV (buf);
|
|
1005
|
|
1006 /* If the output marker is outside of the visible region, save
|
|
1007 the restriction and widen. */
|
|
1008 if (! (BUF_BEGV (buf) <= output_pt && output_pt <= BUF_ZV (buf)))
|
|
1009 {
|
|
1010 record_unwind_protect (save_restriction_restore,
|
|
1011 save_restriction_save (buf));
|
|
1012 Fwiden (wrap_buffer (buf));
|
|
1013 }
|
|
1014
|
|
1015 BUF_SET_PT (buf, output_pt);
|
|
1016 return spec;
|
|
1017 }
|
|
1018
|
428
|
1019 /* Read pending output from the process channel,
|
|
1020 starting with our buffered-ahead character if we have one.
|
|
1021 Yield number of characters read.
|
|
1022
|
|
1023 This function reads at most 1024 bytes.
|
|
1024 If you want to read all available subprocess output,
|
|
1025 you must call it repeatedly until it returns zero. */
|
|
1026
|
|
1027 Charcount
|
853
|
1028 read_process_output (Lisp_Object process, int read_stderr)
|
428
|
1029 {
|
|
1030 /* This function can GC */
|
|
1031 Bytecount nbytes, nchars;
|
771
|
1032 Intbyte chars[1025];
|
428
|
1033 Lisp_Object outstream;
|
444
|
1034 Lisp_Process *p = XPROCESS (process);
|
853
|
1035 Lisp_Object filter = read_stderr ? p->stderr_filter : p->filter;
|
|
1036 Lisp_Object buffer = read_stderr ? p->stderr_buffer : p->buffer;
|
|
1037 Lisp_Object mark = read_stderr ? p->stderr_mark : p->mark;
|
428
|
1038
|
|
1039 /* If there is a lot of output from the subprocess, the loop in
|
|
1040 execute_internal_event() might call read_process_output() more
|
|
1041 than once. If the filter that was executed from one of these
|
|
1042 calls set the filter to t, we have to stop now. Return -1 rather
|
|
1043 than 0 so execute_internal_event() doesn't close the process.
|
|
1044 Really, the loop in execute_internal_event() should check itself
|
|
1045 for a process-filter change, like in status_notify(); but the
|
|
1046 struct Lisp_Process is not exported outside of this file. */
|
440
|
1047 if (!PROCESS_LIVE_P (p))
|
853
|
1048 {
|
|
1049 errno = 0;
|
|
1050 return -1; /* already closed */
|
|
1051 }
|
428
|
1052
|
853
|
1053 if (!NILP (filter) && (p->filter_does_read))
|
428
|
1054 {
|
|
1055 Lisp_Object filter_result;
|
|
1056
|
|
1057 /* Some weird FSFmacs crap here with
|
853
|
1058 Vdeactivate_mark and current_buffer->keymap.
|
|
1059 Some FSF junk with running_asynch_code, to preserve the match
|
|
1060 data. Not necessary because we don't call process filters
|
|
1061 asynchronously (i.e. from within QUIT). */
|
|
1062 /* Don't catch errors here; we're not in any critical code. */
|
|
1063 filter_result = call2 (filter, process, Qnil);
|
428
|
1064 CHECK_INT (filter_result);
|
|
1065 return XINT (filter_result);
|
|
1066 }
|
|
1067
|
853
|
1068 nbytes = Lstream_read (read_stderr ? XLSTREAM (DATA_ERRSTREAM (p)) :
|
|
1069 XLSTREAM (DATA_INSTREAM (p)), chars,
|
771
|
1070 sizeof (chars) - 1);
|
428
|
1071 if (nbytes <= 0) return nbytes;
|
|
1072
|
771
|
1073 if (debug_process_io)
|
|
1074 {
|
|
1075 chars[nbytes] = '\0';
|
|
1076 stderr_out ("Read: %s\n", chars);
|
|
1077 }
|
|
1078
|
|
1079 /* !!#### if the coding system changed as a result of reading, we
|
|
1080 need to change the output coding system accordingly. */
|
428
|
1081 nchars = bytecount_to_charcount (chars, nbytes);
|
853
|
1082 outstream = filter;
|
428
|
1083 if (!NILP (outstream))
|
|
1084 {
|
853
|
1085 /* Some FSF junk with running_asynch_code, to preserve the match
|
|
1086 data. Not necessary because we don't call process filters
|
|
1087 asynchronously (i.e. from within QUIT). */
|
|
1088 /* Don't catch errors here; we're not in any critical code. */
|
|
1089 call2 (outstream, process, make_string (chars, nbytes));
|
428
|
1090 return nchars;
|
|
1091 }
|
|
1092
|
|
1093 /* If no filter, write into buffer if it isn't dead. */
|
853
|
1094 if (!NILP (buffer) && BUFFER_LIVE_P (XBUFFER (buffer)))
|
428
|
1095 {
|
844
|
1096 struct gcpro gcpro1;
|
853
|
1097 struct buffer *buf = XBUFFER (buffer);
|
|
1098 int spec = process_setup_for_insertion (process, read_stderr);
|
428
|
1099
|
844
|
1100 GCPRO1 (process);
|
428
|
1101
|
|
1102 #if 0
|
|
1103 /* This screws up initial display of the window. jla */
|
|
1104
|
|
1105 /* Insert before markers in case we are inserting where
|
|
1106 the buffer's mark is, and the user's next command is Meta-y. */
|
|
1107 buffer_insert_raw_string_1 (buf, -1, chars,
|
|
1108 nbytes, INSDEL_BEFORE_MARKERS);
|
|
1109 #else
|
|
1110 buffer_insert_raw_string (buf, chars, nbytes);
|
|
1111 #endif
|
|
1112
|
853
|
1113 Fset_marker (mark, make_int (BUF_PT (buf)), buffer);
|
|
1114
|
428
|
1115 MARK_MODELINE_CHANGED;
|
844
|
1116 unbind_to (spec);
|
428
|
1117 UNGCPRO;
|
|
1118 }
|
|
1119 return nchars;
|
|
1120 }
|
853
|
1121
|
|
1122 int
|
|
1123 process_has_separate_stderr (Lisp_Object process)
|
|
1124 {
|
|
1125 return XPROCESS (process)->separate_stderr;
|
|
1126 }
|
|
1127
|
428
|
1128
|
|
1129 /* Sending data to subprocess */
|
|
1130
|
444
|
1131 /* send some data to process PROCESS. If NONRELOCATABLE is non-NULL, it
|
428
|
1132 specifies the address of the data. Otherwise, the data comes from the
|
|
1133 object RELOCATABLE (either a string or a buffer). START and LEN
|
|
1134 specify the offset and length of the data to send.
|
|
1135
|
665
|
1136 Note that START and LEN are in Charbpos's if RELOCATABLE is a buffer,
|
428
|
1137 and in Bytecounts otherwise. */
|
|
1138
|
|
1139 void
|
444
|
1140 send_process (Lisp_Object process,
|
665
|
1141 Lisp_Object relocatable, const Intbyte *nonrelocatable,
|
428
|
1142 int start, int len)
|
|
1143 {
|
|
1144 /* This function can GC */
|
|
1145 struct gcpro gcpro1, gcpro2;
|
|
1146 Lisp_Object lstream = Qnil;
|
|
1147
|
444
|
1148 GCPRO2 (process, lstream);
|
428
|
1149
|
444
|
1150 if (NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
563
|
1151 invalid_operation ("Process not open for writing", process);
|
428
|
1152
|
|
1153 if (nonrelocatable)
|
|
1154 lstream =
|
|
1155 make_fixed_buffer_input_stream (nonrelocatable + start, len);
|
|
1156 else if (BUFFERP (relocatable))
|
|
1157 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable),
|
|
1158 start, start + len, 0);
|
|
1159 else
|
|
1160 lstream = make_lisp_string_input_stream (relocatable, start, len);
|
|
1161
|
771
|
1162 if (debug_process_io)
|
|
1163 {
|
|
1164 if (nonrelocatable)
|
|
1165 stderr_out ("Writing: %s\n", nonrelocatable);
|
|
1166 else
|
|
1167 {
|
|
1168 stderr_out ("Writing: ");
|
|
1169 print_internal (relocatable, Qexternal_debugging_output, 0);
|
|
1170 }
|
|
1171 }
|
|
1172
|
444
|
1173 PROCMETH (send_process, (process, XLSTREAM (lstream)));
|
428
|
1174
|
|
1175 UNGCPRO;
|
|
1176 Lstream_delete (XLSTREAM (lstream));
|
|
1177 }
|
|
1178
|
|
1179 DEFUN ("process-tty-name", Fprocess_tty_name, 1, 1, 0, /*
|
|
1180 Return the name of the terminal PROCESS uses, or nil if none.
|
|
1181 This is the terminal that the process itself reads and writes on,
|
|
1182 not the name of the pty that Emacs uses to talk with that terminal.
|
|
1183 */
|
444
|
1184 (process))
|
428
|
1185 {
|
444
|
1186 CHECK_PROCESS (process);
|
|
1187 return MAYBE_LISP_PROCMETH (get_tty_name, (XPROCESS (process)));
|
428
|
1188 }
|
|
1189
|
|
1190 DEFUN ("set-process-buffer", Fset_process_buffer, 2, 2, 0, /*
|
|
1191 Set buffer associated with PROCESS to BUFFER (a buffer, or nil).
|
|
1192 */
|
444
|
1193 (process, buffer))
|
428
|
1194 {
|
444
|
1195 CHECK_PROCESS (process);
|
428
|
1196 if (!NILP (buffer))
|
|
1197 CHECK_BUFFER (buffer);
|
444
|
1198 XPROCESS (process)->buffer = buffer;
|
428
|
1199 return buffer;
|
|
1200 }
|
|
1201
|
|
1202 DEFUN ("process-buffer", Fprocess_buffer, 1, 1, 0, /*
|
|
1203 Return the buffer PROCESS is associated with.
|
|
1204 Output from PROCESS is inserted in this buffer
|
|
1205 unless PROCESS has a filter.
|
|
1206 */
|
444
|
1207 (process))
|
428
|
1208 {
|
444
|
1209 CHECK_PROCESS (process);
|
|
1210 return XPROCESS (process)->buffer;
|
428
|
1211 }
|
|
1212
|
853
|
1213 DEFUN ("set-process-stderr-buffer", Fset_process_stderr_buffer, 2, 2, 0, /*
|
|
1214 Set stderr buffer associated with PROCESS to BUFFER (a buffer, or nil).
|
|
1215 */
|
|
1216 (process, buffer))
|
|
1217 {
|
|
1218 CHECK_PROCESS (process);
|
|
1219 if (!XPROCESS (process)->separate_stderr)
|
|
1220 invalid_change ("stdout and stderr not separate", process);
|
|
1221 if (!NILP (buffer))
|
|
1222 CHECK_BUFFER (buffer);
|
|
1223 XPROCESS (process)->stderr_buffer = buffer;
|
|
1224 return buffer;
|
|
1225 }
|
|
1226
|
|
1227 DEFUN ("process-stderr-buffer", Fprocess_stderr_buffer, 1, 1, 0, /*
|
|
1228 Return the stderr buffer PROCESS is associated with.
|
|
1229 Output from the stderr of PROCESS is inserted in this buffer
|
|
1230 unless PROCESS has a stderr filter.
|
|
1231 */
|
|
1232 (process))
|
|
1233 {
|
|
1234 CHECK_PROCESS (process);
|
|
1235 if (!XPROCESS (process)->separate_stderr)
|
|
1236 invalid_change ("stdout and stderr not separate", process);
|
|
1237 return XPROCESS (process)->stderr_buffer;
|
|
1238 }
|
|
1239
|
428
|
1240 DEFUN ("process-mark", Fprocess_mark, 1, 1, 0, /*
|
|
1241 Return the marker for the end of the last output from PROCESS.
|
|
1242 */
|
444
|
1243 (process))
|
428
|
1244 {
|
444
|
1245 CHECK_PROCESS (process);
|
|
1246 return XPROCESS (process)->mark;
|
428
|
1247 }
|
|
1248
|
853
|
1249 DEFUN ("process-stderr-mark", Fprocess_stderr_mark, 1, 1, 0, /*
|
|
1250 Return the marker for the end of the last stderr output from PROCESS.
|
|
1251 */
|
|
1252 (process))
|
|
1253 {
|
|
1254 CHECK_PROCESS (process);
|
|
1255 if (!XPROCESS (process)->separate_stderr)
|
|
1256 invalid_operation ("stdout and stderr not separate", process);
|
|
1257 return XPROCESS (process)->stderr_mark;
|
|
1258 }
|
|
1259
|
428
|
1260 void
|
853
|
1261 set_process_filter (Lisp_Object process, Lisp_Object filter,
|
|
1262 int filter_does_read, int set_stderr)
|
428
|
1263 {
|
444
|
1264 CHECK_PROCESS (process);
|
853
|
1265 if (set_stderr && !XPROCESS (process)->separate_stderr)
|
|
1266 invalid_change ("stdout and stderr not separate", process);
|
|
1267 if (PROCESS_LIVE_P (XPROCESS (process)))
|
|
1268 {
|
|
1269 if (EQ (filter, Qt))
|
|
1270 event_stream_unselect_process (XPROCESS (process), !set_stderr,
|
|
1271 set_stderr);
|
|
1272 else
|
|
1273 event_stream_select_process (XPROCESS (process), !set_stderr,
|
|
1274 set_stderr);
|
|
1275 }
|
428
|
1276
|
853
|
1277 if (set_stderr)
|
|
1278 XPROCESS (process)->stderr_filter = filter;
|
|
1279 else
|
|
1280 XPROCESS (process)->filter = filter;
|
444
|
1281 XPROCESS (process)->filter_does_read = filter_does_read;
|
428
|
1282 }
|
|
1283
|
|
1284 DEFUN ("set-process-filter", Fset_process_filter, 2, 2, 0, /*
|
|
1285 Give PROCESS the filter function FILTER; nil means no filter.
|
853
|
1286 t means stop accepting output from the process. (If process was created
|
|
1287 with
|
|
1288 When a process has a filter, each time it does output
|
|
1289 the entire string of output is passed to the filter.
|
|
1290 The filter gets two arguments: the process and the string of output.
|
|
1291 If the process has a filter, its buffer is not used for output.
|
|
1292 */
|
|
1293 (process, filter))
|
|
1294 {
|
|
1295 set_process_filter (process, filter, 0, 0);
|
|
1296 return filter;
|
|
1297 }
|
|
1298
|
|
1299 DEFUN ("set-process-stderr-filter", Fset_process_stderr_filter, 2, 2, 0, /*
|
|
1300 Give PROCESS the stderr filter function FILTER; nil means no filter.
|
428
|
1301 t means stop accepting output from the process.
|
|
1302 When a process has a filter, each time it does output
|
|
1303 the entire string of output is passed to the filter.
|
|
1304 The filter gets two arguments: the process and the string of output.
|
|
1305 If the process has a filter, its buffer is not used for output.
|
|
1306 */
|
444
|
1307 (process, filter))
|
428
|
1308 {
|
853
|
1309 set_process_filter (process, filter, 0, 1);
|
428
|
1310 return filter;
|
|
1311 }
|
|
1312
|
|
1313 DEFUN ("process-filter", Fprocess_filter, 1, 1, 0, /*
|
|
1314 Return the filter function of PROCESS; nil if none.
|
|
1315 See `set-process-filter' for more info on filter functions.
|
|
1316 */
|
444
|
1317 (process))
|
428
|
1318 {
|
444
|
1319 CHECK_PROCESS (process);
|
|
1320 return XPROCESS (process)->filter;
|
428
|
1321 }
|
|
1322
|
853
|
1323 DEFUN ("process-stderr-filter", Fprocess_stderr_filter, 1, 1, 0, /*
|
|
1324 Return the filter function of PROCESS; nil if none.
|
|
1325 See `set-process-stderr-filter' for more info on filter functions.
|
|
1326 */
|
|
1327 (process))
|
|
1328 {
|
|
1329 CHECK_PROCESS (process);
|
|
1330 if (!XPROCESS (process)->separate_stderr)
|
|
1331 invalid_operation ("stdout and stderr not separate", process);
|
|
1332 return XPROCESS (process)->stderr_filter;
|
|
1333 }
|
|
1334
|
442
|
1335 DEFUN ("process-send-region", Fprocess_send_region, 3, 4, 0, /*
|
|
1336 Send current contents of the region between START and END as input to PROCESS.
|
444
|
1337 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1338 name of a buffer, in which case the buffer's process is used. If it
|
|
1339 is nil, the current buffer's process is used.
|
442
|
1340 BUFFER specifies the buffer to look in; if nil, the current buffer is used.
|
853
|
1341 If the region is more than 100 or so characters long, it may be sent in
|
|
1342 several chunks. This may happen even for shorter regions. Output
|
444
|
1343 from processes can arrive in between chunks.
|
428
|
1344 */
|
442
|
1345 (process, start, end, buffer))
|
428
|
1346 {
|
|
1347 /* This function can GC */
|
665
|
1348 Charbpos bstart, bend;
|
442
|
1349 struct buffer *buf = decode_buffer (buffer, 0);
|
428
|
1350
|
793
|
1351 buffer = wrap_buffer (buf);
|
444
|
1352 process = get_process (process);
|
|
1353 get_buffer_range_char (buf, start, end, &bstart, &bend, 0);
|
442
|
1354
|
444
|
1355 send_process (process, buffer, 0, bstart, bend - bstart);
|
428
|
1356 return Qnil;
|
|
1357 }
|
|
1358
|
|
1359 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /*
|
|
1360 Send PROCESS the contents of STRING as input.
|
444
|
1361 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1362 name of a buffer, in which case the buffer's process is used. If it
|
|
1363 is nil, the current buffer's process is used.
|
|
1364 Optional arguments START and END specify part of STRING; see `substring'.
|
|
1365 If STRING is more than 100 or so characters long, it may be sent in
|
|
1366 several chunks. This may happen even for shorter strings. Output
|
|
1367 from processes can arrive in between chunks.
|
428
|
1368 */
|
444
|
1369 (process, string, start, end))
|
428
|
1370 {
|
|
1371 /* This function can GC */
|
444
|
1372 Bytecount bstart, bend;
|
428
|
1373
|
444
|
1374 process = get_process (process);
|
428
|
1375 CHECK_STRING (string);
|
444
|
1376 get_string_range_byte (string, start, end, &bstart, &bend,
|
428
|
1377 GB_HISTORICAL_STRING_BEHAVIOR);
|
|
1378
|
444
|
1379 send_process (process, string, 0, bstart, bend - bstart);
|
428
|
1380 return Qnil;
|
|
1381 }
|
|
1382
|
|
1383
|
|
1384 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /*
|
|
1385 Return PROCESS's input coding system.
|
|
1386 */
|
|
1387 (process))
|
|
1388 {
|
|
1389 process = get_process (process);
|
440
|
1390 CHECK_LIVE_PROCESS (process);
|
771
|
1391 return (coding_stream_detected_coding_system
|
|
1392 (XLSTREAM (XPROCESS (process)->coding_instream)));
|
428
|
1393 }
|
|
1394
|
|
1395 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /*
|
|
1396 Return PROCESS's output coding system.
|
|
1397 */
|
|
1398 (process))
|
|
1399 {
|
|
1400 process = get_process (process);
|
440
|
1401 CHECK_LIVE_PROCESS (process);
|
771
|
1402 return (coding_stream_coding_system
|
|
1403 (XLSTREAM (XPROCESS (process)->coding_outstream)));
|
428
|
1404 }
|
|
1405
|
|
1406 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /*
|
|
1407 Return a pair of coding-system for decoding and encoding of PROCESS.
|
|
1408 */
|
|
1409 (process))
|
|
1410 {
|
|
1411 process = get_process (process);
|
440
|
1412 CHECK_LIVE_PROCESS (process);
|
771
|
1413 return Fcons (coding_stream_detected_coding_system
|
428
|
1414 (XLSTREAM (XPROCESS (process)->coding_instream)),
|
771
|
1415 coding_stream_coding_system
|
428
|
1416 (XLSTREAM (XPROCESS (process)->coding_outstream)));
|
|
1417 }
|
|
1418
|
|
1419 DEFUN ("set-process-input-coding-system", Fset_process_input_coding_system,
|
|
1420 2, 2, 0, /*
|
|
1421 Set PROCESS's input coding system to CODESYS.
|
771
|
1422 This is used for reading data from PROCESS.
|
428
|
1423 */
|
|
1424 (process, codesys))
|
|
1425 {
|
771
|
1426 codesys = get_coding_system_for_text_file (codesys, 1);
|
428
|
1427 process = get_process (process);
|
440
|
1428 CHECK_LIVE_PROCESS (process);
|
|
1429
|
771
|
1430 set_coding_stream_coding_system
|
428
|
1431 (XLSTREAM (XPROCESS (process)->coding_instream), codesys);
|
|
1432 return Qnil;
|
|
1433 }
|
|
1434
|
|
1435 DEFUN ("set-process-output-coding-system", Fset_process_output_coding_system,
|
|
1436 2, 2, 0, /*
|
|
1437 Set PROCESS's output coding system to CODESYS.
|
771
|
1438 This is used for writing data to PROCESS.
|
428
|
1439 */
|
|
1440 (process, codesys))
|
|
1441 {
|
771
|
1442 codesys = get_coding_system_for_text_file (codesys, 0);
|
428
|
1443 process = get_process (process);
|
440
|
1444 CHECK_LIVE_PROCESS (process);
|
|
1445
|
771
|
1446 set_coding_stream_coding_system
|
428
|
1447 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys);
|
|
1448 return Qnil;
|
|
1449 }
|
|
1450
|
|
1451 DEFUN ("set-process-coding-system", Fset_process_coding_system,
|
|
1452 1, 3, 0, /*
|
|
1453 Set coding-systems of PROCESS to DECODING and ENCODING.
|
440
|
1454 DECODING will be used to decode subprocess output and ENCODING to
|
|
1455 encode subprocess input.
|
428
|
1456 */
|
|
1457 (process, decoding, encoding))
|
|
1458 {
|
|
1459 if (!NILP (decoding))
|
|
1460 Fset_process_input_coding_system (process, decoding);
|
|
1461
|
|
1462 if (!NILP (encoding))
|
|
1463 Fset_process_output_coding_system (process, encoding);
|
|
1464
|
|
1465 return Qnil;
|
|
1466 }
|
|
1467
|
|
1468
|
|
1469 /************************************************************************/
|
|
1470 /* process status */
|
|
1471 /************************************************************************/
|
|
1472
|
|
1473 static Lisp_Object
|
|
1474 exec_sentinel_unwind (Lisp_Object datum)
|
|
1475 {
|
853
|
1476 XPROCESS (XCAR (datum))->sentinel = XCDR (datum);
|
|
1477 free_cons (datum);
|
428
|
1478 return Qnil;
|
|
1479 }
|
|
1480
|
|
1481 static void
|
444
|
1482 exec_sentinel (Lisp_Object process, Lisp_Object reason)
|
428
|
1483 {
|
|
1484 /* This function can GC */
|
|
1485 int speccount = specpdl_depth ();
|
444
|
1486 Lisp_Process *p = XPROCESS (process);
|
428
|
1487 Lisp_Object sentinel = p->sentinel;
|
|
1488
|
|
1489 if (NILP (sentinel))
|
|
1490 return;
|
|
1491
|
|
1492 /* Some weird FSFmacs crap here with
|
|
1493 Vdeactivate_mark and current_buffer->keymap */
|
|
1494
|
853
|
1495 /* Some FSF junk with running_asynch_code, to preserve the match
|
|
1496 data. Not necessary because we don't call process filters
|
|
1497 asynchronously (i.e. from within QUIT). */
|
|
1498
|
428
|
1499 /* Zilch the sentinel while it's running, to avoid recursive invocations;
|
853
|
1500 assure that it gets restored no matter how the sentinel exits.
|
|
1501
|
|
1502 (#### Why is this necessary? Probably another relic of asynchronous
|
|
1503 calling of process filters/sentinels.) */
|
428
|
1504 p->sentinel = Qnil;
|
853
|
1505 record_unwind_protect (exec_sentinel_unwind,
|
|
1506 noseeum_cons (process, sentinel));
|
|
1507 /* Don't catch errors here; we're not in any critical code. */
|
|
1508 call2 (sentinel, process, reason);
|
771
|
1509 unbind_to (speccount);
|
428
|
1510 }
|
|
1511
|
|
1512 DEFUN ("set-process-sentinel", Fset_process_sentinel, 2, 2, 0, /*
|
|
1513 Give PROCESS the sentinel SENTINEL; nil for none.
|
|
1514 The sentinel is called as a function when the process changes state.
|
|
1515 It gets two arguments: the process, and a string describing the change.
|
|
1516 */
|
444
|
1517 (process, sentinel))
|
428
|
1518 {
|
444
|
1519 CHECK_PROCESS (process);
|
|
1520 XPROCESS (process)->sentinel = sentinel;
|
428
|
1521 return sentinel;
|
|
1522 }
|
|
1523
|
|
1524 DEFUN ("process-sentinel", Fprocess_sentinel, 1, 1, 0, /*
|
|
1525 Return the sentinel of PROCESS; nil if none.
|
|
1526 See `set-process-sentinel' for more info on sentinels.
|
|
1527 */
|
444
|
1528 (process))
|
428
|
1529 {
|
444
|
1530 CHECK_PROCESS (process);
|
|
1531 return XPROCESS (process)->sentinel;
|
428
|
1532 }
|
|
1533
|
|
1534
|
442
|
1535 const char *
|
428
|
1536 signal_name (int signum)
|
|
1537 {
|
|
1538 if (signum >= 0 && signum < NSIG)
|
442
|
1539 return (const char *) sys_siglist[signum];
|
428
|
1540
|
442
|
1541 return (const char *) GETTEXT ("unknown signal");
|
428
|
1542 }
|
|
1543
|
|
1544 void
|
|
1545 update_process_status (Lisp_Object p,
|
|
1546 Lisp_Object status_symbol,
|
|
1547 int exit_code,
|
|
1548 int core_dumped)
|
|
1549 {
|
|
1550 XPROCESS (p)->tick++;
|
|
1551 process_tick++;
|
|
1552 XPROCESS (p)->status_symbol = status_symbol;
|
|
1553 XPROCESS (p)->exit_code = exit_code;
|
|
1554 XPROCESS (p)->core_dumped = core_dumped;
|
|
1555 }
|
|
1556
|
|
1557 /* Return a string describing a process status list. */
|
|
1558
|
|
1559 static Lisp_Object
|
440
|
1560 status_message (Lisp_Process *p)
|
428
|
1561 {
|
|
1562 Lisp_Object symbol = p->status_symbol;
|
|
1563 int code = p->exit_code;
|
|
1564 int coredump = p->core_dumped;
|
|
1565 Lisp_Object string, string2;
|
|
1566
|
|
1567 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop))
|
|
1568 {
|
|
1569 string = build_string (signal_name (code));
|
|
1570 if (coredump)
|
771
|
1571 string2 = build_msg_string (" (core dumped)\n");
|
428
|
1572 else
|
|
1573 string2 = build_string ("\n");
|
793
|
1574 set_string_char (string, 0,
|
826
|
1575 DOWNCASE (0, string_emchar (string, 0)));
|
428
|
1576 return concat2 (string, string2);
|
|
1577 }
|
|
1578 else if (EQ (symbol, Qexit))
|
|
1579 {
|
|
1580 if (code == 0)
|
771
|
1581 return build_msg_string ("finished\n");
|
428
|
1582 string = Fnumber_to_string (make_int (code));
|
|
1583 if (coredump)
|
771
|
1584 string2 = build_msg_string (" (core dumped)\n");
|
428
|
1585 else
|
|
1586 string2 = build_string ("\n");
|
771
|
1587 return concat2 (build_msg_string ("exited abnormally with code "),
|
428
|
1588 concat2 (string, string2));
|
|
1589 }
|
|
1590 else
|
|
1591 return Fcopy_sequence (Fsymbol_name (symbol));
|
|
1592 }
|
|
1593
|
|
1594 /* Tell status_notify() to check for terminated processes. We do this
|
|
1595 because on some systems we sometimes miss SIGCHLD calls. (Not sure
|
853
|
1596 why.) This is also used under Mswin. */
|
428
|
1597
|
|
1598 void
|
|
1599 kick_status_notify (void)
|
|
1600 {
|
|
1601 process_tick++;
|
|
1602 }
|
|
1603
|
|
1604
|
|
1605 /* Report all recent events of a change in process status
|
|
1606 (either run the sentinel or output a message).
|
|
1607 This is done while Emacs is waiting for keyboard input. */
|
|
1608
|
|
1609 void
|
|
1610 status_notify (void)
|
|
1611 {
|
|
1612 /* This function can GC */
|
|
1613 Lisp_Object tail = Qnil;
|
|
1614 Lisp_Object symbol = Qnil;
|
|
1615 Lisp_Object msg = Qnil;
|
|
1616 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1617 /* process_tick is volatile, so we have to remember it now.
|
444
|
1618 Otherwise, we get a race condition if SIGCHLD happens during
|
428
|
1619 this function.
|
|
1620
|
|
1621 (Actually, this is not the case anymore. The code to
|
|
1622 update the process structures has been moved out of the
|
|
1623 SIGCHLD handler. But for the moment I'm leaving this
|
|
1624 stuff in -- it can't hurt.) */
|
|
1625 int temp_process_tick;
|
|
1626
|
|
1627 MAYBE_PROCMETH (reap_exited_processes, ());
|
|
1628
|
|
1629 temp_process_tick = process_tick;
|
|
1630
|
|
1631 if (update_tick == temp_process_tick)
|
|
1632 return;
|
|
1633
|
|
1634 /* We need to gcpro tail; if read_process_output calls a filter
|
|
1635 which deletes a process and removes the cons to which tail points
|
|
1636 from Vprocess_alist, and then causes a GC, tail is an unprotected
|
|
1637 reference. */
|
|
1638 GCPRO3 (tail, symbol, msg);
|
|
1639
|
|
1640 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail))
|
|
1641 {
|
444
|
1642 Lisp_Object process = XCAR (tail);
|
|
1643 Lisp_Process *p = XPROCESS (process);
|
428
|
1644 /* p->tick is also volatile. Same thing as above applies. */
|
|
1645 int this_process_tick;
|
|
1646
|
|
1647 /* #### extra check for terminated processes, in case a SIGCHLD
|
|
1648 got missed (this seems to happen sometimes, I'm not sure why).
|
|
1649 */
|
|
1650 if (INTP (p->pid))
|
|
1651 MAYBE_PROCMETH (update_status_if_terminated, (p));
|
|
1652
|
|
1653 this_process_tick = p->tick;
|
|
1654 if (this_process_tick != p->update_tick)
|
|
1655 {
|
|
1656 p->update_tick = this_process_tick;
|
|
1657
|
|
1658 /* If process is still active, read any output that remains. */
|
|
1659 while (!EQ (p->filter, Qt)
|
853
|
1660 && read_process_output (process, 0) > 0)
|
|
1661 ;
|
|
1662 while (p->separate_stderr && !EQ (p->stderr_filter, Qt)
|
|
1663 && read_process_output (process, 1) > 0)
|
428
|
1664 ;
|
|
1665
|
|
1666 /* Get the text to use for the message. */
|
|
1667 msg = status_message (p);
|
|
1668
|
|
1669 /* If process is terminated, deactivate it or delete it. */
|
|
1670 symbol = p->status_symbol;
|
|
1671
|
|
1672 if (EQ (symbol, Qsignal)
|
|
1673 || EQ (symbol, Qexit))
|
|
1674 {
|
|
1675 if (delete_exited_processes)
|
444
|
1676 remove_process (process);
|
428
|
1677 else
|
444
|
1678 deactivate_process (process);
|
428
|
1679 }
|
|
1680
|
|
1681 /* Now output the message suitably. */
|
|
1682 if (!NILP (p->sentinel))
|
444
|
1683 exec_sentinel (process, msg);
|
428
|
1684 /* Don't bother with a message in the buffer
|
|
1685 when a process becomes runnable. */
|
844
|
1686 else if (!EQ (symbol, Qrun) && !NILP (p->buffer) &&
|
|
1687 /* Avoid error if buffer is deleted
|
|
1688 (probably that's why the process is dead, too) */
|
|
1689 BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
428
|
1690 {
|
844
|
1691 struct gcpro ngcpro1;
|
853
|
1692 int spec = process_setup_for_insertion (process, 0);
|
428
|
1693
|
844
|
1694 NGCPRO1 (process);
|
428
|
1695 buffer_insert_c_string (current_buffer, "\nProcess ");
|
|
1696 Finsert (1, &p->name);
|
|
1697 buffer_insert_c_string (current_buffer, " ");
|
|
1698 Finsert (1, &msg);
|
|
1699 Fset_marker (p->mark, make_int (BUF_PT (current_buffer)),
|
|
1700 p->buffer);
|
|
1701
|
844
|
1702 unbind_to (spec);
|
428
|
1703 NUNGCPRO;
|
|
1704 }
|
|
1705 }
|
|
1706 } /* end for */
|
|
1707
|
|
1708 /* in case buffers use %s in modeline-format */
|
|
1709 MARK_MODELINE_CHANGED;
|
|
1710 redisplay ();
|
|
1711
|
|
1712 update_tick = temp_process_tick;
|
|
1713
|
|
1714 UNGCPRO;
|
|
1715 }
|
|
1716
|
|
1717 DEFUN ("process-status", Fprocess_status, 1, 1, 0, /*
|
|
1718 Return the status of PROCESS.
|
|
1719 This is a symbol, one of these:
|
|
1720
|
|
1721 run -- for a process that is running.
|
|
1722 stop -- for a process stopped but continuable.
|
|
1723 exit -- for a process that has exited.
|
|
1724 signal -- for a process that has got a fatal signal.
|
|
1725 open -- for a network stream connection that is open.
|
|
1726 closed -- for a network stream connection that is closed.
|
|
1727 nil -- if arg is a process name and no such process exists.
|
|
1728
|
|
1729 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1730 nil, indicating the current buffer's process.
|
|
1731 */
|
444
|
1732 (process))
|
428
|
1733 {
|
|
1734 Lisp_Object status_symbol;
|
|
1735
|
444
|
1736 if (STRINGP (process))
|
|
1737 process = Fget_process (process);
|
428
|
1738 else
|
444
|
1739 process = get_process (process);
|
428
|
1740
|
444
|
1741 if (NILP (process))
|
428
|
1742 return Qnil;
|
|
1743
|
444
|
1744 status_symbol = XPROCESS (process)->status_symbol;
|
|
1745 if (network_connection_p (process))
|
428
|
1746 {
|
|
1747 if (EQ (status_symbol, Qrun))
|
|
1748 status_symbol = Qopen;
|
|
1749 else if (EQ (status_symbol, Qexit))
|
|
1750 status_symbol = Qclosed;
|
|
1751 }
|
|
1752 return status_symbol;
|
|
1753 }
|
|
1754
|
|
1755 DEFUN ("process-exit-status", Fprocess_exit_status, 1, 1, 0, /*
|
|
1756 Return the exit status of PROCESS or the signal number that killed it.
|
|
1757 If PROCESS has not yet exited or died, return 0.
|
|
1758 */
|
444
|
1759 (process))
|
428
|
1760 {
|
444
|
1761 CHECK_PROCESS (process);
|
|
1762 return make_int (XPROCESS (process)->exit_code);
|
428
|
1763 }
|
|
1764
|
|
1765
|
|
1766
|
442
|
1767 static int
|
|
1768 decode_signal (Lisp_Object signal_)
|
428
|
1769 {
|
442
|
1770 if (INTP (signal_))
|
|
1771 return XINT (signal_);
|
428
|
1772 else
|
|
1773 {
|
665
|
1774 Intbyte *name;
|
428
|
1775
|
442
|
1776 CHECK_SYMBOL (signal_);
|
793
|
1777 name = XSTRING_DATA (XSYMBOL (signal_)->name);
|
428
|
1778
|
793
|
1779 #define handle_signal(sym) do { \
|
|
1780 if (!qxestrcmp_c ( name, #sym)) \
|
|
1781 return sym; \
|
442
|
1782 } while (0)
|
428
|
1783
|
|
1784 handle_signal (SIGINT); /* ANSI */
|
|
1785 handle_signal (SIGILL); /* ANSI */
|
|
1786 handle_signal (SIGABRT); /* ANSI */
|
|
1787 handle_signal (SIGFPE); /* ANSI */
|
|
1788 handle_signal (SIGSEGV); /* ANSI */
|
|
1789 handle_signal (SIGTERM); /* ANSI */
|
|
1790
|
|
1791 #ifdef SIGHUP
|
|
1792 handle_signal (SIGHUP); /* POSIX */
|
|
1793 #endif
|
|
1794 #ifdef SIGQUIT
|
|
1795 handle_signal (SIGQUIT); /* POSIX */
|
|
1796 #endif
|
|
1797 #ifdef SIGTRAP
|
|
1798 handle_signal (SIGTRAP); /* POSIX */
|
|
1799 #endif
|
|
1800 #ifdef SIGKILL
|
|
1801 handle_signal (SIGKILL); /* POSIX */
|
|
1802 #endif
|
|
1803 #ifdef SIGUSR1
|
|
1804 handle_signal (SIGUSR1); /* POSIX */
|
|
1805 #endif
|
|
1806 #ifdef SIGUSR2
|
|
1807 handle_signal (SIGUSR2); /* POSIX */
|
|
1808 #endif
|
|
1809 #ifdef SIGPIPE
|
|
1810 handle_signal (SIGPIPE); /* POSIX */
|
|
1811 #endif
|
|
1812 #ifdef SIGALRM
|
|
1813 handle_signal (SIGALRM); /* POSIX */
|
|
1814 #endif
|
|
1815 #ifdef SIGCHLD
|
|
1816 handle_signal (SIGCHLD); /* POSIX */
|
|
1817 #endif
|
|
1818 #ifdef SIGCONT
|
|
1819 handle_signal (SIGCONT); /* POSIX */
|
|
1820 #endif
|
|
1821 #ifdef SIGSTOP
|
|
1822 handle_signal (SIGSTOP); /* POSIX */
|
|
1823 #endif
|
|
1824 #ifdef SIGTSTP
|
|
1825 handle_signal (SIGTSTP); /* POSIX */
|
|
1826 #endif
|
|
1827 #ifdef SIGTTIN
|
|
1828 handle_signal (SIGTTIN); /* POSIX */
|
|
1829 #endif
|
|
1830 #ifdef SIGTTOU
|
|
1831 handle_signal (SIGTTOU); /* POSIX */
|
|
1832 #endif
|
|
1833
|
|
1834 #ifdef SIGBUS
|
|
1835 handle_signal (SIGBUS); /* XPG5 */
|
|
1836 #endif
|
|
1837 #ifdef SIGPOLL
|
|
1838 handle_signal (SIGPOLL); /* XPG5 */
|
|
1839 #endif
|
|
1840 #ifdef SIGPROF
|
|
1841 handle_signal (SIGPROF); /* XPG5 */
|
|
1842 #endif
|
|
1843 #ifdef SIGSYS
|
|
1844 handle_signal (SIGSYS); /* XPG5 */
|
|
1845 #endif
|
|
1846 #ifdef SIGURG
|
|
1847 handle_signal (SIGURG); /* XPG5 */
|
|
1848 #endif
|
|
1849 #ifdef SIGXCPU
|
|
1850 handle_signal (SIGXCPU); /* XPG5 */
|
|
1851 #endif
|
|
1852 #ifdef SIGXFSZ
|
|
1853 handle_signal (SIGXFSZ); /* XPG5 */
|
|
1854 #endif
|
|
1855 #ifdef SIGVTALRM
|
|
1856 handle_signal (SIGVTALRM); /* XPG5 */
|
|
1857 #endif
|
|
1858
|
|
1859 #ifdef SIGIO
|
|
1860 handle_signal (SIGIO); /* BSD 4.2 */
|
|
1861 #endif
|
|
1862 #ifdef SIGWINCH
|
|
1863 handle_signal (SIGWINCH); /* BSD 4.3 */
|
|
1864 #endif
|
|
1865
|
|
1866 #ifdef SIGEMT
|
|
1867 handle_signal (SIGEMT);
|
|
1868 #endif
|
|
1869 #ifdef SIGINFO
|
|
1870 handle_signal (SIGINFO);
|
|
1871 #endif
|
|
1872 #ifdef SIGHWE
|
|
1873 handle_signal (SIGHWE);
|
|
1874 #endif
|
|
1875 #ifdef SIGPRE
|
|
1876 handle_signal (SIGPRE);
|
|
1877 #endif
|
|
1878 #ifdef SIGUME
|
|
1879 handle_signal (SIGUME);
|
|
1880 #endif
|
|
1881 #ifdef SIGDLK
|
|
1882 handle_signal (SIGDLK);
|
|
1883 #endif
|
|
1884 #ifdef SIGCPULIM
|
|
1885 handle_signal (SIGCPULIM);
|
|
1886 #endif
|
|
1887 #ifdef SIGIOT
|
|
1888 handle_signal (SIGIOT);
|
|
1889 #endif
|
|
1890 #ifdef SIGLOST
|
|
1891 handle_signal (SIGLOST);
|
|
1892 #endif
|
|
1893 #ifdef SIGSTKFLT
|
|
1894 handle_signal (SIGSTKFLT);
|
|
1895 #endif
|
|
1896 #ifdef SIGUNUSED
|
|
1897 handle_signal (SIGUNUSED);
|
|
1898 #endif
|
|
1899 #ifdef SIGDANGER
|
|
1900 handle_signal (SIGDANGER); /* AIX */
|
|
1901 #endif
|
|
1902 #ifdef SIGMSG
|
|
1903 handle_signal (SIGMSG);
|
|
1904 #endif
|
|
1905 #ifdef SIGSOUND
|
|
1906 handle_signal (SIGSOUND);
|
|
1907 #endif
|
|
1908 #ifdef SIGRETRACT
|
|
1909 handle_signal (SIGRETRACT);
|
|
1910 #endif
|
|
1911 #ifdef SIGGRANT
|
|
1912 handle_signal (SIGGRANT);
|
|
1913 #endif
|
|
1914 #ifdef SIGPWR
|
|
1915 handle_signal (SIGPWR);
|
|
1916 #endif
|
|
1917
|
|
1918 #undef handle_signal
|
|
1919
|
563
|
1920 invalid_constant ("Undefined signal name", signal_);
|
801
|
1921 RETURN_NOT_REACHED (0)
|
442
|
1922 }
|
|
1923 }
|
|
1924
|
|
1925 /* Send signal number SIGNO to PROCESS.
|
|
1926 CURRENT-GROUP non-nil means send signal to the current
|
|
1927 foreground process group of the process's controlling terminal rather
|
|
1928 than to the process's own process group.
|
|
1929 This is used for various commands in shell mode.
|
|
1930 If NOMSG is zero, insert signal-announcements into process's buffers
|
|
1931 right away.
|
|
1932
|
|
1933 If we can, we try to signal PROCESS by sending control characters
|
|
1934 down the pty. This allows us to signal inferiors who have changed
|
|
1935 their uid, for which kill() would return an EPERM error, or to
|
|
1936 processes running on another computer through a remote login. */
|
|
1937
|
|
1938 static void
|
|
1939 process_send_signal (Lisp_Object process, int signo,
|
|
1940 int current_group, int nomsg)
|
|
1941 {
|
|
1942 /* This function can GC */
|
444
|
1943 process = get_process (process);
|
442
|
1944
|
444
|
1945 if (network_connection_p (process))
|
563
|
1946 invalid_operation ("Network connection is not a subprocess", process);
|
444
|
1947 CHECK_LIVE_PROCESS (process);
|
442
|
1948
|
444
|
1949 MAYBE_PROCMETH (kill_child_process, (process, signo, current_group, nomsg));
|
442
|
1950 }
|
|
1951
|
|
1952 DEFUN ("process-send-signal", Fprocess_send_signal, 1, 3, 0, /*
|
|
1953 Send signal SIGNAL to process PROCESS.
|
|
1954 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
1955 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1956 nil, indicating the current buffer's process.
|
|
1957 Third arg CURRENT-GROUP non-nil means send signal to the current
|
|
1958 foreground process group of the process's controlling terminal rather
|
|
1959 than to the process's own process group.
|
|
1960 If the process is a shell that supports job control, this means
|
|
1961 send the signal to the current subjob rather than the shell.
|
|
1962 */
|
|
1963 (signal_, process, current_group))
|
|
1964 {
|
|
1965 /* This function can GC */
|
|
1966 process_send_signal (process, decode_signal (signal_),
|
|
1967 !NILP (current_group), 0);
|
|
1968 return process;
|
|
1969 }
|
|
1970
|
|
1971 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /*
|
|
1972 Interrupt process PROCESS.
|
|
1973 See function `process-send-signal' for more details on usage.
|
|
1974 */
|
|
1975 (process, current_group))
|
|
1976 {
|
|
1977 /* This function can GC */
|
|
1978 process_send_signal (process, SIGINT, !NILP (current_group), 0);
|
|
1979 return process;
|
|
1980 }
|
|
1981
|
|
1982 DEFUN ("kill-process", Fkill_process, 0, 2, 0, /*
|
|
1983 Kill process PROCESS.
|
|
1984 See function `process-send-signal' for more details on usage.
|
|
1985 */
|
|
1986 (process, current_group))
|
|
1987 {
|
|
1988 /* This function can GC */
|
|
1989 #ifdef SIGKILL
|
|
1990 process_send_signal (process, SIGKILL, !NILP (current_group), 0);
|
|
1991 #else
|
563
|
1992 signal_error (Qunimplemented,
|
|
1993 "kill-process: Not supported on this system",
|
|
1994 Qunbound);
|
442
|
1995 #endif
|
|
1996 return process;
|
|
1997 }
|
|
1998
|
|
1999 DEFUN ("quit-process", Fquit_process, 0, 2, 0, /*
|
|
2000 Send QUIT signal to process PROCESS.
|
|
2001 See function `process-send-signal' for more details on usage.
|
|
2002 */
|
|
2003 (process, current_group))
|
|
2004 {
|
|
2005 /* This function can GC */
|
|
2006 #ifdef SIGQUIT
|
|
2007 process_send_signal (process, SIGQUIT, !NILP (current_group), 0);
|
|
2008 #else
|
563
|
2009 signal_error (Qunimplemented,
|
|
2010 "quit-process: Not supported on this system",
|
|
2011 Qunbound);
|
442
|
2012 #endif
|
|
2013 return process;
|
|
2014 }
|
|
2015
|
|
2016 DEFUN ("stop-process", Fstop_process, 0, 2, 0, /*
|
|
2017 Stop process PROCESS.
|
|
2018 See function `process-send-signal' for more details on usage.
|
|
2019 */
|
|
2020 (process, current_group))
|
|
2021 {
|
|
2022 /* This function can GC */
|
|
2023 #ifdef SIGTSTP
|
|
2024 process_send_signal (process, SIGTSTP, !NILP (current_group), 0);
|
|
2025 #else
|
563
|
2026 signal_error (Qunimplemented,
|
|
2027 "stop-process: Not supported on this system",
|
|
2028 Qunbound);
|
442
|
2029 #endif
|
|
2030 return process;
|
|
2031 }
|
|
2032
|
|
2033 DEFUN ("continue-process", Fcontinue_process, 0, 2, 0, /*
|
|
2034 Continue process PROCESS.
|
|
2035 See function `process-send-signal' for more details on usage.
|
|
2036 */
|
|
2037 (process, current_group))
|
|
2038 {
|
|
2039 /* This function can GC */
|
|
2040 #ifdef SIGCONT
|
|
2041 process_send_signal (process, SIGCONT, !NILP (current_group), 0);
|
|
2042 #else
|
563
|
2043 signal_error (Qunimplemented,
|
|
2044 "continue-process: Not supported on this system",
|
|
2045 Qunbound);
|
442
|
2046 #endif
|
|
2047 return process;
|
|
2048 }
|
|
2049
|
|
2050 DEFUN ("signal-process", Fsignal_process, 2, 2,
|
|
2051 "nProcess number: \nnSignal code: ", /*
|
|
2052 Send the process with process id PID the signal with code SIGNAL.
|
|
2053 PID must be an integer. The process need not be a child of this Emacs.
|
|
2054 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
2055 */
|
|
2056 (pid, signal_))
|
|
2057 {
|
|
2058 CHECK_INT (pid);
|
|
2059
|
428
|
2060 return make_int (PROCMETH_OR_GIVEN (kill_process_by_pid,
|
442
|
2061 (XINT (pid), decode_signal (signal_)),
|
|
2062 -1));
|
428
|
2063 }
|
|
2064
|
|
2065 DEFUN ("process-send-eof", Fprocess_send_eof, 0, 1, 0, /*
|
|
2066 Make PROCESS see end-of-file in its input.
|
|
2067 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
2068 nil, indicating the current buffer's process.
|
|
2069 If PROCESS is a network connection, or is a process communicating
|
|
2070 through a pipe (as opposed to a pty), then you cannot send any more
|
|
2071 text to PROCESS after you call this function.
|
|
2072 */
|
|
2073 (process))
|
|
2074 {
|
|
2075 /* This function can GC */
|
444
|
2076 process = get_process (process);
|
428
|
2077
|
|
2078 /* Make sure the process is really alive. */
|
444
|
2079 if (! EQ (XPROCESS (process)->status_symbol, Qrun))
|
563
|
2080 invalid_operation ("Process not running", process);
|
428
|
2081
|
444
|
2082 if (!MAYBE_INT_PROCMETH (process_send_eof, (process)))
|
428
|
2083 {
|
444
|
2084 if (!NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
428
|
2085 {
|
853
|
2086 USID humpty, dumpty;
|
444
|
2087 Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process))));
|
853
|
2088 event_stream_delete_io_streams (Qnil,
|
|
2089 XPROCESS (process)->pipe_outstream,
|
|
2090 Qnil, &humpty, &dumpty);
|
444
|
2091 XPROCESS (process)->pipe_outstream = Qnil;
|
|
2092 XPROCESS (process)->coding_outstream = Qnil;
|
428
|
2093 }
|
|
2094 }
|
|
2095
|
|
2096 return process;
|
|
2097 }
|
|
2098
|
|
2099
|
|
2100 /************************************************************************/
|
|
2101 /* deleting a process */
|
|
2102 /************************************************************************/
|
|
2103
|
|
2104 void
|
444
|
2105 deactivate_process (Lisp_Object process)
|
428
|
2106 {
|
444
|
2107 Lisp_Process *p = XPROCESS (process);
|
853
|
2108 USID in_usid, err_usid;
|
428
|
2109
|
|
2110 /* It's possible that we got as far in the process-creation
|
|
2111 process as creating the descriptors but didn't get so
|
|
2112 far as selecting the process for input. In this
|
|
2113 case, p->pid is nil: p->pid is set at the same time that
|
|
2114 the process is selected for input. */
|
|
2115 /* #### The comment does not look correct. event_stream_unselect_process
|
853
|
2116 is guarded by process->*_selected, so this is not a problem. - kkm*/
|
428
|
2117 /* Must call this before setting the streams to nil */
|
853
|
2118 event_stream_unselect_process (p, 1, 1);
|
428
|
2119
|
|
2120 if (!NILP (DATA_OUTSTREAM (p)))
|
|
2121 Lstream_close (XLSTREAM (DATA_OUTSTREAM (p)));
|
|
2122 if (!NILP (DATA_INSTREAM (p)))
|
|
2123 Lstream_close (XLSTREAM (DATA_INSTREAM (p)));
|
853
|
2124 if (!NILP (DATA_ERRSTREAM (p)))
|
|
2125 Lstream_close (XLSTREAM (DATA_ERRSTREAM (p)));
|
428
|
2126
|
|
2127 /* Provide minimal implementation for deactivate_process
|
|
2128 if there's no process-specific one */
|
|
2129 if (HAS_PROCMETH_P (deactivate_process))
|
853
|
2130 PROCMETH (deactivate_process, (p, &in_usid, &err_usid));
|
428
|
2131 else
|
853
|
2132 event_stream_delete_io_streams (p->pipe_instream,
|
|
2133 p->pipe_outstream,
|
|
2134 p->pipe_errstream,
|
|
2135 &in_usid, &err_usid);
|
428
|
2136
|
853
|
2137 if (in_usid != USID_DONTHASH)
|
|
2138 remhash ((const void*)in_usid, usid_to_process);
|
|
2139 if (err_usid != USID_DONTHASH)
|
|
2140 remhash ((const void*)err_usid, usid_to_process);
|
428
|
2141
|
|
2142 p->pipe_instream = Qnil;
|
|
2143 p->pipe_outstream = Qnil;
|
853
|
2144 p->pipe_errstream = Qnil;
|
428
|
2145 p->coding_instream = Qnil;
|
|
2146 p->coding_outstream = Qnil;
|
853
|
2147 p->coding_errstream = Qnil;
|
428
|
2148 }
|
|
2149
|
|
2150 static void
|
444
|
2151 remove_process (Lisp_Object process)
|
428
|
2152 {
|
444
|
2153 Vprocess_list = delq_no_quit (process, Vprocess_list);
|
|
2154 Fset_marker (XPROCESS (process)->mark, Qnil, Qnil);
|
428
|
2155
|
444
|
2156 deactivate_process (process);
|
428
|
2157 }
|
|
2158
|
|
2159 DEFUN ("delete-process", Fdelete_process, 1, 1, 0, /*
|
|
2160 Delete PROCESS: kill it and forget about it immediately.
|
|
2161 PROCESS may be a process or the name of one, or a buffer name.
|
|
2162 */
|
444
|
2163 (process))
|
428
|
2164 {
|
|
2165 /* This function can GC */
|
440
|
2166 Lisp_Process *p;
|
444
|
2167 process = get_process (process);
|
|
2168 p = XPROCESS (process);
|
|
2169 if (network_connection_p (process))
|
428
|
2170 {
|
|
2171 p->status_symbol = Qexit;
|
|
2172 p->exit_code = 0;
|
|
2173 p->core_dumped = 0;
|
|
2174 p->tick++;
|
|
2175 process_tick++;
|
|
2176 }
|
440
|
2177 else if (PROCESS_LIVE_P (p))
|
428
|
2178 {
|
444
|
2179 Fkill_process (process, Qnil);
|
428
|
2180 /* Do this now, since remove_process will make sigchld_handler do nothing. */
|
|
2181 p->status_symbol = Qsignal;
|
|
2182 p->exit_code = SIGKILL;
|
|
2183 p->core_dumped = 0;
|
|
2184 p->tick++;
|
|
2185 process_tick++;
|
|
2186 status_notify ();
|
|
2187 }
|
444
|
2188 remove_process (process);
|
428
|
2189 return Qnil;
|
|
2190 }
|
|
2191
|
|
2192 /* Kill all processes associated with `buffer'.
|
|
2193 If `buffer' is nil, kill all processes */
|
|
2194
|
|
2195 void
|
|
2196 kill_buffer_processes (Lisp_Object buffer)
|
|
2197 {
|
444
|
2198 LIST_LOOP_2 (process, Vprocess_list)
|
|
2199 if ((NILP (buffer) || EQ (XPROCESS (process)->buffer, buffer)))
|
|
2200 {
|
|
2201 if (network_connection_p (process))
|
|
2202 Fdelete_process (process);
|
|
2203 else if (PROCESS_LIVE_P (XPROCESS (process)))
|
|
2204 process_send_signal (process, SIGHUP, 0, 1);
|
|
2205 }
|
428
|
2206 }
|
|
2207
|
|
2208 DEFUN ("process-kill-without-query", Fprocess_kill_without_query, 1, 2, 0, /*
|
|
2209 Say no query needed if PROCESS is running when Emacs is exited.
|
|
2210 Optional second argument if non-nil says to require a query.
|
|
2211 Value is t if a query was formerly required.
|
|
2212 */
|
444
|
2213 (process, require_query_p))
|
428
|
2214 {
|
|
2215 int tem;
|
|
2216
|
444
|
2217 CHECK_PROCESS (process);
|
|
2218 tem = XPROCESS (process)->kill_without_query;
|
|
2219 XPROCESS (process)->kill_without_query = NILP (require_query_p);
|
428
|
2220
|
|
2221 return tem ? Qnil : Qt;
|
|
2222 }
|
|
2223
|
|
2224 DEFUN ("process-kill-without-query-p", Fprocess_kill_without_query_p, 1, 1, 0, /*
|
444
|
2225 Return t if PROCESS will be killed without query when emacs is exited.
|
428
|
2226 */
|
444
|
2227 (process))
|
428
|
2228 {
|
444
|
2229 CHECK_PROCESS (process);
|
|
2230 return XPROCESS (process)->kill_without_query ? Qt : Qnil;
|
428
|
2231 }
|
|
2232
|
|
2233
|
|
2234 #if 0
|
|
2235
|
826
|
2236 DEFUN ("process-connection", Fprocess_connection, 0, 1, 0, /*
|
428
|
2237 Return the connection type of `PROCESS'. This can be nil (pipe),
|
|
2238 t or pty (pty) or stream (socket connection).
|
|
2239 */
|
|
2240 (process))
|
|
2241 {
|
|
2242 return XPROCESS (process)->type;
|
|
2243 }
|
|
2244
|
|
2245 #endif /* 0 */
|
|
2246
|
814
|
2247
|
|
2248 static int
|
|
2249 getenv_internal (const Intbyte *var,
|
|
2250 Bytecount varlen,
|
|
2251 Intbyte **value,
|
|
2252 Bytecount *valuelen)
|
|
2253 {
|
|
2254 Lisp_Object scan;
|
|
2255
|
|
2256 assert (env_initted);
|
|
2257
|
|
2258 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
2259 {
|
|
2260 Lisp_Object entry = XCAR (scan);
|
|
2261
|
|
2262 if (STRINGP (entry)
|
|
2263 && XSTRING_LENGTH (entry) > varlen
|
826
|
2264 && string_byte (entry, varlen) == '='
|
814
|
2265 #ifdef WIN32_NATIVE
|
|
2266 /* NT environment variables are case insensitive. */
|
|
2267 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
|
2268 #else /* not WIN32_NATIVE */
|
|
2269 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
|
2270 #endif /* not WIN32_NATIVE */
|
|
2271 )
|
|
2272 {
|
|
2273 *value = XSTRING_DATA (entry) + (varlen + 1);
|
|
2274 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1);
|
|
2275 return 1;
|
|
2276 }
|
|
2277 }
|
|
2278
|
|
2279 return 0;
|
|
2280 }
|
|
2281
|
|
2282 static void
|
|
2283 putenv_internal (const Intbyte *var,
|
|
2284 Bytecount varlen,
|
|
2285 const Intbyte *value,
|
|
2286 Bytecount valuelen)
|
|
2287 {
|
|
2288 Lisp_Object scan;
|
|
2289
|
|
2290 assert (env_initted);
|
|
2291
|
|
2292 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
2293 {
|
|
2294 Lisp_Object entry = XCAR (scan);
|
|
2295
|
|
2296 if (STRINGP (entry)
|
|
2297 && XSTRING_LENGTH (entry) > varlen
|
826
|
2298 && string_byte (entry, varlen) == '='
|
814
|
2299 #ifdef WIN32_NATIVE
|
|
2300 /* NT environment variables are case insensitive. */
|
|
2301 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
|
2302 #else /* not WIN32_NATIVE */
|
|
2303 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
|
2304 #endif /* not WIN32_NATIVE */
|
|
2305 )
|
|
2306 {
|
|
2307 XCAR (scan) = concat3 (make_string (var, varlen),
|
|
2308 build_string ("="),
|
|
2309 make_string (value, valuelen));
|
|
2310 return;
|
|
2311 }
|
|
2312 }
|
|
2313
|
|
2314 Vprocess_environment = Fcons (concat3 (make_string (var, varlen),
|
|
2315 build_string ("="),
|
|
2316 make_string (value, valuelen)),
|
|
2317 Vprocess_environment);
|
|
2318 }
|
|
2319
|
|
2320 /* NOTE:
|
|
2321
|
|
2322 FSF has this as a Lisp function, as follows. Generally moving things
|
|
2323 out of C and into Lisp is a good idea, but in this case the Lisp
|
|
2324 function is used so early in the startup sequence that it would be ugly
|
|
2325 to rearrange the early dumped code to accommodate this.
|
|
2326
|
|
2327 (defun getenv (variable)
|
|
2328 "Get the value of environment variable VARIABLE.
|
|
2329 VARIABLE should be a string. Value is nil if VARIABLE is undefined in
|
|
2330 the environment. Otherwise, value is a string.
|
|
2331
|
|
2332 This function consults the variable `process-environment'
|
|
2333 for its value."
|
|
2334 (interactive (list (read-envvar-name "Get environment variable: " t)))
|
|
2335 (let ((value (getenv-internal variable)))
|
|
2336 (when (interactive-p)
|
|
2337 (message "%s" (if value value "Not set")))
|
|
2338 value))
|
|
2339 */
|
|
2340
|
|
2341 DEFUN ("getenv", Fgetenv, 1, 2, "sEnvironment variable: \np", /*
|
|
2342 Return the value of environment variable VAR, as a string.
|
|
2343 VAR is a string, the name of the variable.
|
|
2344 When invoked interactively, prints the value in the echo area.
|
|
2345 */
|
|
2346 (var, interactivep))
|
|
2347 {
|
|
2348 Intbyte *value;
|
|
2349 Bytecount valuelen;
|
|
2350 Lisp_Object v = Qnil;
|
|
2351 struct gcpro gcpro1;
|
|
2352
|
|
2353 CHECK_STRING (var);
|
|
2354 GCPRO1 (v);
|
|
2355 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var),
|
|
2356 &value, &valuelen))
|
|
2357 v = make_string (value, valuelen);
|
|
2358 if (!NILP (interactivep))
|
|
2359 {
|
|
2360 if (NILP (v))
|
|
2361 message ("%s not defined in environment", XSTRING_DATA (var));
|
|
2362 else
|
|
2363 /* #### Should use Fprin1_to_string or Fprin1 to handle string
|
|
2364 containing quotes correctly. */
|
|
2365 message ("\"%s\"", value);
|
|
2366 }
|
|
2367 RETURN_UNGCPRO (v);
|
|
2368 }
|
|
2369
|
|
2370 /* A version of getenv that consults Vprocess_environment, easily
|
|
2371 callable from C.
|
|
2372
|
|
2373 (At init time, Vprocess_environment is initialized from the
|
|
2374 environment, stored in the global variable environ. [Note that
|
|
2375 at startup time, `environ' should be the same as the envp parameter
|
|
2376 passed to main(); however, later calls to putenv() may change
|
|
2377 `environ', making the envp parameter inaccurate.] Calls to getenv()
|
|
2378 and putenv() consult and modify `environ'. However, once
|
|
2379 Vprocess_environment is initted, XEmacs C code should *NEVER* call
|
|
2380 getenv() or putenv() directly, because (1) Lisp code that modifies
|
|
2381 the environment only modifies Vprocess_environment, not `environ';
|
|
2382 and (2) Vprocess_environment is in internal format but `environ'
|
|
2383 is in some external format, and getenv()/putenv() are not Mule-
|
|
2384 encapsulated.
|
|
2385
|
|
2386 WARNING: This value points into Lisp string data and thus will become
|
|
2387 invalid after a GC. */
|
|
2388
|
|
2389 Intbyte *
|
|
2390 egetenv (const CIntbyte *var)
|
|
2391 {
|
|
2392 /* This cannot GC -- 7-28-00 ben */
|
|
2393 Intbyte *value;
|
|
2394 Bytecount valuelen;
|
|
2395
|
|
2396 if (getenv_internal ((const Intbyte *) var, strlen (var), &value, &valuelen))
|
|
2397 return value;
|
|
2398 else
|
|
2399 return 0;
|
|
2400 }
|
|
2401
|
|
2402 void
|
|
2403 eputenv (const CIntbyte *var, const CIntbyte *value)
|
|
2404 {
|
|
2405 putenv_internal ((Intbyte *) var, strlen (var), (Intbyte *) value,
|
|
2406 strlen (value));
|
|
2407 }
|
|
2408
|
|
2409
|
|
2410 /* This is not named init_process in order to avoid a conflict with NS 3.3 */
|
|
2411 void
|
|
2412 init_xemacs_process (void)
|
|
2413 {
|
|
2414 /* This function can GC */
|
|
2415
|
|
2416 MAYBE_PROCMETH (init_process, ());
|
|
2417
|
|
2418 Vprocess_list = Qnil;
|
|
2419
|
|
2420 if (usid_to_process)
|
|
2421 clrhash (usid_to_process);
|
|
2422 else
|
|
2423 usid_to_process = make_hash_table (32);
|
|
2424
|
|
2425 {
|
|
2426 /* jwz: always initialize Vprocess_environment, so that egetenv()
|
|
2427 works in temacs. */
|
|
2428 char **envp;
|
|
2429 Vprocess_environment = Qnil;
|
|
2430 for (envp = environ; envp && *envp; envp++)
|
|
2431 Vprocess_environment =
|
|
2432 Fcons (build_ext_string (*envp, Qnative), Vprocess_environment);
|
|
2433 /* This gets set back to 0 in disksave_object_finalization() */
|
|
2434 env_initted = 1;
|
|
2435 }
|
|
2436
|
|
2437 {
|
|
2438 /* Initialize shell-file-name from environment variables or best guess. */
|
|
2439 #ifdef WIN32_NATIVE
|
|
2440 const Intbyte *shell = egetenv ("SHELL");
|
|
2441 if (!shell) shell = egetenv ("COMSPEC");
|
|
2442 /* Should never happen! */
|
|
2443 if (!shell) shell =
|
|
2444 (Intbyte *) (GetVersion () & 0x80000000 ? "command" : "cmd");
|
|
2445 #else /* not WIN32_NATIVE */
|
|
2446 const Intbyte *shell = egetenv ("SHELL");
|
|
2447 if (!shell) shell = (Intbyte *) "/bin/sh";
|
|
2448 #endif
|
|
2449
|
|
2450 #if 0 /* defined (WIN32_NATIVE) */
|
|
2451 /* BAD BAD BAD. We do not wanting to be passing an XEmacs-created
|
|
2452 SHELL var down to some inferior Cygwin process, which might get
|
|
2453 screwed up.
|
|
2454
|
|
2455 There are a few broken apps (eterm/term.el, eterm/tshell.el,
|
|
2456 os-utils/terminal.el, texinfo/tex-mode.el) where this will
|
|
2457 cause problems. Those broken apps don't look at
|
|
2458 shell-file-name, instead just at explicit-shell-file-name,
|
|
2459 ESHELL and SHELL. They are apparently attempting to borrow
|
|
2460 what `M-x shell' uses, but that latter also looks at
|
|
2461 shell-file-name. What we want is for all of these apps to look
|
|
2462 at shell-file-name, so that the user can change the value of
|
|
2463 shell-file-name and everything will work out hunky-dorey.
|
|
2464 */
|
|
2465
|
|
2466 if (!egetenv ("SHELL"))
|
|
2467 {
|
|
2468 Intbyte *faux_var = alloca_array (Intbyte, 7 + qxestrlen (shell));
|
|
2469 qxesprintf (faux_var, "SHELL=%s", shell);
|
|
2470 Vprocess_environment = Fcons (build_intstring (faux_var),
|
|
2471 Vprocess_environment);
|
|
2472 }
|
|
2473 #endif /* 0 */
|
|
2474
|
|
2475 Vshell_file_name = build_intstring (shell);
|
|
2476 }
|
|
2477 }
|
|
2478
|
428
|
2479 void
|
|
2480 syms_of_process (void)
|
|
2481 {
|
442
|
2482 INIT_LRECORD_IMPLEMENTATION (process);
|
|
2483
|
563
|
2484 DEFSYMBOL (Qprocessp);
|
|
2485 DEFSYMBOL (Qprocess_live_p);
|
|
2486 DEFSYMBOL (Qrun);
|
|
2487 DEFSYMBOL (Qstop);
|
|
2488 DEFSYMBOL (Qopen);
|
|
2489 DEFSYMBOL (Qclosed);
|
428
|
2490
|
563
|
2491 DEFSYMBOL (Qtcp);
|
|
2492 DEFSYMBOL (Qudp);
|
428
|
2493
|
|
2494 #ifdef HAVE_MULTICAST
|
563
|
2495 DEFSYMBOL (Qmulticast); /* Used for occasional warnings */
|
428
|
2496 #endif
|
|
2497
|
563
|
2498 DEFERROR_STANDARD (Qprocess_error, Qio_error);
|
|
2499 DEFERROR_STANDARD (Qnetwork_error, Qio_error);
|
|
2500
|
428
|
2501 DEFSUBR (Fprocessp);
|
440
|
2502 DEFSUBR (Fprocess_live_p);
|
428
|
2503 DEFSUBR (Fget_process);
|
|
2504 DEFSUBR (Fget_buffer_process);
|
|
2505 DEFSUBR (Fdelete_process);
|
|
2506 DEFSUBR (Fprocess_status);
|
|
2507 DEFSUBR (Fprocess_exit_status);
|
|
2508 DEFSUBR (Fprocess_id);
|
|
2509 DEFSUBR (Fprocess_name);
|
|
2510 DEFSUBR (Fprocess_tty_name);
|
|
2511 DEFSUBR (Fprocess_command);
|
|
2512 DEFSUBR (Fset_process_buffer);
|
853
|
2513 DEFSUBR (Fset_process_stderr_buffer);
|
428
|
2514 DEFSUBR (Fprocess_buffer);
|
|
2515 DEFSUBR (Fprocess_mark);
|
853
|
2516 DEFSUBR (Fprocess_stderr_buffer);
|
|
2517 DEFSUBR (Fprocess_stderr_mark);
|
428
|
2518 DEFSUBR (Fset_process_filter);
|
|
2519 DEFSUBR (Fprocess_filter);
|
853
|
2520 DEFSUBR (Fset_process_stderr_filter);
|
|
2521 DEFSUBR (Fprocess_stderr_filter);
|
428
|
2522 DEFSUBR (Fset_process_window_size);
|
|
2523 DEFSUBR (Fset_process_sentinel);
|
|
2524 DEFSUBR (Fprocess_sentinel);
|
|
2525 DEFSUBR (Fprocess_kill_without_query);
|
|
2526 DEFSUBR (Fprocess_kill_without_query_p);
|
|
2527 DEFSUBR (Fprocess_list);
|
|
2528 DEFSUBR (Fstart_process_internal);
|
|
2529 #ifdef HAVE_SOCKETS
|
|
2530 DEFSUBR (Fopen_network_stream_internal);
|
|
2531 #ifdef HAVE_MULTICAST
|
|
2532 DEFSUBR (Fopen_multicast_group_internal);
|
|
2533 #endif /* HAVE_MULTICAST */
|
|
2534 #endif /* HAVE_SOCKETS */
|
|
2535 DEFSUBR (Fprocess_send_region);
|
|
2536 DEFSUBR (Fprocess_send_string);
|
442
|
2537 DEFSUBR (Fprocess_send_signal);
|
428
|
2538 DEFSUBR (Finterrupt_process);
|
|
2539 DEFSUBR (Fkill_process);
|
|
2540 DEFSUBR (Fquit_process);
|
|
2541 DEFSUBR (Fstop_process);
|
|
2542 DEFSUBR (Fcontinue_process);
|
|
2543 DEFSUBR (Fprocess_send_eof);
|
|
2544 DEFSUBR (Fsignal_process);
|
|
2545 /* DEFSUBR (Fprocess_connection); */
|
|
2546 DEFSUBR (Fprocess_input_coding_system);
|
|
2547 DEFSUBR (Fprocess_output_coding_system);
|
|
2548 DEFSUBR (Fset_process_input_coding_system);
|
|
2549 DEFSUBR (Fset_process_output_coding_system);
|
|
2550 DEFSUBR (Fprocess_coding_system);
|
|
2551 DEFSUBR (Fset_process_coding_system);
|
814
|
2552 DEFSUBR (Fgetenv);
|
428
|
2553 }
|
|
2554
|
|
2555 void
|
|
2556 vars_of_process (void)
|
|
2557 {
|
|
2558 Fprovide (intern ("subprocesses"));
|
|
2559 #ifdef HAVE_SOCKETS
|
|
2560 Fprovide (intern ("network-streams"));
|
|
2561 #ifdef HAVE_MULTICAST
|
|
2562 Fprovide (intern ("multicast"));
|
|
2563 #endif /* HAVE_MULTICAST */
|
|
2564 #endif /* HAVE_SOCKETS */
|
|
2565 staticpro (&Vprocess_list);
|
|
2566
|
|
2567 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes /*
|
|
2568 *Non-nil means delete processes immediately when they exit.
|
|
2569 nil means don't delete them until `list-processes' is run.
|
|
2570 */ );
|
|
2571
|
|
2572 delete_exited_processes = 1;
|
|
2573
|
442
|
2574 DEFVAR_CONST_LISP ("null-device", &Vnull_device /*
|
|
2575 Name of the null device, which differs from system to system.
|
|
2576 The null device is a filename that acts as a sink for arbitrary amounts of
|
|
2577 data, which is discarded, or as a source for a zero-length file.
|
|
2578 It is available on all the systems that we currently support, but with
|
|
2579 different names (typically either `/dev/null' or `nul').
|
|
2580
|
|
2581 Note that there is also a /dev/zero on most modern Unix versions (including
|
|
2582 Cygwin), which acts like /dev/null when used as a sink, but as a source
|
|
2583 it sends a non-ending stream of zero bytes. It's used most often along
|
|
2584 with memory-mapping. We don't provide a Lisp variable for this because
|
|
2585 the operations needing this are lower level than what ELisp programs
|
|
2586 typically do, and in any case no equivalent exists under native MS Windows.
|
|
2587 */ );
|
|
2588 Vnull_device = build_string (NULL_DEVICE);
|
|
2589
|
428
|
2590 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /*
|
|
2591 Control type of device used to communicate with subprocesses.
|
|
2592 Values are nil to use a pipe, or t or `pty' to use a pty.
|
|
2593 The value has no effect if the system has no ptys or if all ptys are busy:
|
|
2594 then a pipe is used in any case.
|
|
2595 The value takes effect when `start-process' is called.
|
|
2596 */ );
|
|
2597 Vprocess_connection_type = Qt;
|
|
2598
|
|
2599 DEFVAR_BOOL ("windowed-process-io", &windowed_process_io /*
|
|
2600 Enables input/output on standard handles of a windowed process.
|
|
2601 When this variable is nil (the default), XEmacs does not attempt to read
|
|
2602 standard output handle of a windowed process. Instead, the process is
|
|
2603 immediately marked as exited immediately upon successful launching. This is
|
|
2604 done because normal windowed processes do not use standard I/O, as they are
|
|
2605 not connected to any console.
|
|
2606
|
|
2607 When launching a specially crafted windowed process, which expects to be
|
|
2608 launched by XEmacs, or by other program which pipes its standard input and
|
|
2609 output, this variable must be set to non-nil, in which case XEmacs will
|
|
2610 treat this process just like a console process.
|
|
2611
|
|
2612 NOTE: You should never set this variable, only bind it.
|
|
2613
|
|
2614 Only Windows processes can be "windowed" or "console". This variable has no
|
|
2615 effect on UNIX processes, because all UNIX processes are "console".
|
|
2616 */ );
|
|
2617 windowed_process_io = 0;
|
|
2618
|
771
|
2619 DEFVAR_INT ("debug-process-io", &debug_process_io /*
|
|
2620 If non-zero, display data sent to or received from a process.
|
|
2621 */ );
|
|
2622 debug_process_io = 0;
|
|
2623
|
|
2624 DEFVAR_LISP ("default-process-coding-system",
|
|
2625 &Vdefault_process_coding_system /*
|
|
2626 Cons of coding systems used for process I/O by default.
|
|
2627 The car part is used for reading (decoding) data from a process, and
|
|
2628 the cdr part is used for writing (encoding) data to a process.
|
|
2629 */ );
|
|
2630 /* This below will get its default set correctly in code-init.el. */
|
|
2631 Vdefault_process_coding_system = Fcons (Qundecided, Qnil);
|
|
2632
|
853
|
2633 DEFVAR_LISP ("default-network-coding-system",
|
|
2634 &Vdefault_network_coding_system /*
|
|
2635 Cons of coding systems used for network I/O by default.
|
|
2636 The car part is used for reading (decoding) data from a process, and
|
|
2637 the cdr part is used for writing (encoding) data to a process.
|
|
2638 */ );
|
|
2639 Vdefault_network_coding_system = Fcons (Qundecided, Qnil);
|
|
2640
|
428
|
2641 #ifdef PROCESS_IO_BLOCKING
|
|
2642 DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /*
|
|
2643 List of port numbers or port names to set a blocking I/O mode with connection.
|
|
2644 Nil value means to set a default(non-blocking) I/O mode.
|
|
2645 The value takes effect when `open-network-stream-internal' is called.
|
|
2646 */ );
|
|
2647 network_stream_blocking_port_list = Qnil;
|
|
2648 #endif /* PROCESS_IO_BLOCKING */
|
814
|
2649
|
|
2650 /* This function can GC */
|
|
2651 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /*
|
|
2652 *File name to load inferior shells from.
|
|
2653 Initialized from the SHELL environment variable.
|
|
2654 */ );
|
428
|
2655
|
814
|
2656 DEFVAR_LISP ("process-environment", &Vprocess_environment /*
|
|
2657 List of environment variables for subprocesses to inherit.
|
|
2658 Each element should be a string of the form ENVVARNAME=VALUE.
|
|
2659 The environment which Emacs inherits is placed in this variable
|
|
2660 when Emacs starts.
|
|
2661 */ );
|
|
2662
|
|
2663 Vlisp_EXEC_SUFFIXES = build_string (EXEC_SUFFIXES);
|
|
2664 staticpro (&Vlisp_EXEC_SUFFIXES);
|
|
2665 }
|