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"
|
859
|
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);
|
854
|
997
|
844
|
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
|
859
|
1128 DEFUN ("process-has-separate-stderr-p", Fprocess_has_separate_stderr_p, 1, 1,
|
|
1129 0, /*
|
|
1130 Return non-nil if process has stderr separate from stdout.
|
|
1131 */
|
|
1132 (process))
|
|
1133 {
|
|
1134 CHECK_PROCESS (process);
|
|
1135 return process_has_separate_stderr (process) ? Qt : Qnil;
|
|
1136 }
|
|
1137
|
428
|
1138
|
|
1139 /* Sending data to subprocess */
|
|
1140
|
444
|
1141 /* send some data to process PROCESS. If NONRELOCATABLE is non-NULL, it
|
428
|
1142 specifies the address of the data. Otherwise, the data comes from the
|
|
1143 object RELOCATABLE (either a string or a buffer). START and LEN
|
|
1144 specify the offset and length of the data to send.
|
|
1145
|
665
|
1146 Note that START and LEN are in Charbpos's if RELOCATABLE is a buffer,
|
428
|
1147 and in Bytecounts otherwise. */
|
|
1148
|
|
1149 void
|
444
|
1150 send_process (Lisp_Object process,
|
665
|
1151 Lisp_Object relocatable, const Intbyte *nonrelocatable,
|
428
|
1152 int start, int len)
|
|
1153 {
|
|
1154 /* This function can GC */
|
|
1155 struct gcpro gcpro1, gcpro2;
|
|
1156 Lisp_Object lstream = Qnil;
|
|
1157
|
444
|
1158 GCPRO2 (process, lstream);
|
428
|
1159
|
444
|
1160 if (NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
563
|
1161 invalid_operation ("Process not open for writing", process);
|
428
|
1162
|
|
1163 if (nonrelocatable)
|
|
1164 lstream =
|
|
1165 make_fixed_buffer_input_stream (nonrelocatable + start, len);
|
|
1166 else if (BUFFERP (relocatable))
|
|
1167 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable),
|
|
1168 start, start + len, 0);
|
|
1169 else
|
|
1170 lstream = make_lisp_string_input_stream (relocatable, start, len);
|
|
1171
|
771
|
1172 if (debug_process_io)
|
|
1173 {
|
|
1174 if (nonrelocatable)
|
|
1175 stderr_out ("Writing: %s\n", nonrelocatable);
|
|
1176 else
|
|
1177 {
|
|
1178 stderr_out ("Writing: ");
|
|
1179 print_internal (relocatable, Qexternal_debugging_output, 0);
|
|
1180 }
|
|
1181 }
|
|
1182
|
444
|
1183 PROCMETH (send_process, (process, XLSTREAM (lstream)));
|
428
|
1184
|
|
1185 UNGCPRO;
|
|
1186 Lstream_delete (XLSTREAM (lstream));
|
|
1187 }
|
|
1188
|
|
1189 DEFUN ("process-tty-name", Fprocess_tty_name, 1, 1, 0, /*
|
|
1190 Return the name of the terminal PROCESS uses, or nil if none.
|
|
1191 This is the terminal that the process itself reads and writes on,
|
|
1192 not the name of the pty that Emacs uses to talk with that terminal.
|
|
1193 */
|
444
|
1194 (process))
|
428
|
1195 {
|
444
|
1196 CHECK_PROCESS (process);
|
|
1197 return MAYBE_LISP_PROCMETH (get_tty_name, (XPROCESS (process)));
|
428
|
1198 }
|
|
1199
|
|
1200 DEFUN ("set-process-buffer", Fset_process_buffer, 2, 2, 0, /*
|
|
1201 Set buffer associated with PROCESS to BUFFER (a buffer, or nil).
|
|
1202 */
|
444
|
1203 (process, buffer))
|
428
|
1204 {
|
444
|
1205 CHECK_PROCESS (process);
|
428
|
1206 if (!NILP (buffer))
|
|
1207 CHECK_BUFFER (buffer);
|
444
|
1208 XPROCESS (process)->buffer = buffer;
|
428
|
1209 return buffer;
|
|
1210 }
|
|
1211
|
|
1212 DEFUN ("process-buffer", Fprocess_buffer, 1, 1, 0, /*
|
|
1213 Return the buffer PROCESS is associated with.
|
|
1214 Output from PROCESS is inserted in this buffer
|
|
1215 unless PROCESS has a filter.
|
|
1216 */
|
444
|
1217 (process))
|
428
|
1218 {
|
444
|
1219 CHECK_PROCESS (process);
|
|
1220 return XPROCESS (process)->buffer;
|
428
|
1221 }
|
|
1222
|
853
|
1223 DEFUN ("set-process-stderr-buffer", Fset_process_stderr_buffer, 2, 2, 0, /*
|
|
1224 Set stderr buffer associated with PROCESS to BUFFER (a buffer, or nil).
|
|
1225 */
|
|
1226 (process, buffer))
|
|
1227 {
|
|
1228 CHECK_PROCESS (process);
|
|
1229 if (!XPROCESS (process)->separate_stderr)
|
|
1230 invalid_change ("stdout and stderr not separate", process);
|
|
1231 if (!NILP (buffer))
|
|
1232 CHECK_BUFFER (buffer);
|
|
1233 XPROCESS (process)->stderr_buffer = buffer;
|
|
1234 return buffer;
|
|
1235 }
|
|
1236
|
|
1237 DEFUN ("process-stderr-buffer", Fprocess_stderr_buffer, 1, 1, 0, /*
|
|
1238 Return the stderr buffer PROCESS is associated with.
|
|
1239 Output from the stderr of PROCESS is inserted in this buffer
|
|
1240 unless PROCESS has a stderr filter.
|
|
1241 */
|
|
1242 (process))
|
|
1243 {
|
|
1244 CHECK_PROCESS (process);
|
|
1245 if (!XPROCESS (process)->separate_stderr)
|
|
1246 invalid_change ("stdout and stderr not separate", process);
|
|
1247 return XPROCESS (process)->stderr_buffer;
|
|
1248 }
|
|
1249
|
428
|
1250 DEFUN ("process-mark", Fprocess_mark, 1, 1, 0, /*
|
|
1251 Return the marker for the end of the last output from PROCESS.
|
|
1252 */
|
444
|
1253 (process))
|
428
|
1254 {
|
444
|
1255 CHECK_PROCESS (process);
|
|
1256 return XPROCESS (process)->mark;
|
428
|
1257 }
|
|
1258
|
853
|
1259 DEFUN ("process-stderr-mark", Fprocess_stderr_mark, 1, 1, 0, /*
|
|
1260 Return the marker for the end of the last stderr output from PROCESS.
|
|
1261 */
|
|
1262 (process))
|
|
1263 {
|
|
1264 CHECK_PROCESS (process);
|
|
1265 if (!XPROCESS (process)->separate_stderr)
|
|
1266 invalid_operation ("stdout and stderr not separate", process);
|
|
1267 return XPROCESS (process)->stderr_mark;
|
|
1268 }
|
|
1269
|
428
|
1270 void
|
853
|
1271 set_process_filter (Lisp_Object process, Lisp_Object filter,
|
|
1272 int filter_does_read, int set_stderr)
|
428
|
1273 {
|
444
|
1274 CHECK_PROCESS (process);
|
853
|
1275 if (set_stderr && !XPROCESS (process)->separate_stderr)
|
|
1276 invalid_change ("stdout and stderr not separate", process);
|
|
1277 if (PROCESS_LIVE_P (XPROCESS (process)))
|
|
1278 {
|
|
1279 if (EQ (filter, Qt))
|
|
1280 event_stream_unselect_process (XPROCESS (process), !set_stderr,
|
|
1281 set_stderr);
|
|
1282 else
|
|
1283 event_stream_select_process (XPROCESS (process), !set_stderr,
|
|
1284 set_stderr);
|
|
1285 }
|
428
|
1286
|
853
|
1287 if (set_stderr)
|
|
1288 XPROCESS (process)->stderr_filter = filter;
|
|
1289 else
|
|
1290 XPROCESS (process)->filter = filter;
|
444
|
1291 XPROCESS (process)->filter_does_read = filter_does_read;
|
428
|
1292 }
|
|
1293
|
|
1294 DEFUN ("set-process-filter", Fset_process_filter, 2, 2, 0, /*
|
|
1295 Give PROCESS the filter function FILTER; nil means no filter.
|
853
|
1296 t means stop accepting output from the process. (If process was created
|
854
|
1297 with
|
853
|
1298 When a process has a filter, each time it does output
|
|
1299 the entire string of output is passed to the filter.
|
|
1300 The filter gets two arguments: the process and the string of output.
|
|
1301 If the process has a filter, its buffer is not used for output.
|
|
1302 */
|
|
1303 (process, filter))
|
|
1304 {
|
|
1305 set_process_filter (process, filter, 0, 0);
|
|
1306 return filter;
|
|
1307 }
|
|
1308
|
|
1309 DEFUN ("set-process-stderr-filter", Fset_process_stderr_filter, 2, 2, 0, /*
|
|
1310 Give PROCESS the stderr filter function FILTER; nil means no filter.
|
428
|
1311 t means stop accepting output from the process.
|
|
1312 When a process has a filter, each time it does output
|
|
1313 the entire string of output is passed to the filter.
|
|
1314 The filter gets two arguments: the process and the string of output.
|
|
1315 If the process has a filter, its buffer is not used for output.
|
|
1316 */
|
444
|
1317 (process, filter))
|
428
|
1318 {
|
853
|
1319 set_process_filter (process, filter, 0, 1);
|
428
|
1320 return filter;
|
|
1321 }
|
|
1322
|
|
1323 DEFUN ("process-filter", Fprocess_filter, 1, 1, 0, /*
|
|
1324 Return the filter function of PROCESS; nil if none.
|
|
1325 See `set-process-filter' for more info on filter functions.
|
|
1326 */
|
444
|
1327 (process))
|
428
|
1328 {
|
444
|
1329 CHECK_PROCESS (process);
|
|
1330 return XPROCESS (process)->filter;
|
428
|
1331 }
|
|
1332
|
853
|
1333 DEFUN ("process-stderr-filter", Fprocess_stderr_filter, 1, 1, 0, /*
|
|
1334 Return the filter function of PROCESS; nil if none.
|
|
1335 See `set-process-stderr-filter' for more info on filter functions.
|
|
1336 */
|
|
1337 (process))
|
|
1338 {
|
|
1339 CHECK_PROCESS (process);
|
|
1340 if (!XPROCESS (process)->separate_stderr)
|
|
1341 invalid_operation ("stdout and stderr not separate", process);
|
|
1342 return XPROCESS (process)->stderr_filter;
|
|
1343 }
|
|
1344
|
442
|
1345 DEFUN ("process-send-region", Fprocess_send_region, 3, 4, 0, /*
|
|
1346 Send current contents of the region between START and END as input to PROCESS.
|
444
|
1347 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1348 name of a buffer, in which case the buffer's process is used. If it
|
|
1349 is nil, the current buffer's process is used.
|
442
|
1350 BUFFER specifies the buffer to look in; if nil, the current buffer is used.
|
853
|
1351 If the region is more than 100 or so characters long, it may be sent in
|
|
1352 several chunks. This may happen even for shorter regions. Output
|
444
|
1353 from processes can arrive in between chunks.
|
428
|
1354 */
|
442
|
1355 (process, start, end, buffer))
|
428
|
1356 {
|
|
1357 /* This function can GC */
|
665
|
1358 Charbpos bstart, bend;
|
442
|
1359 struct buffer *buf = decode_buffer (buffer, 0);
|
428
|
1360
|
793
|
1361 buffer = wrap_buffer (buf);
|
444
|
1362 process = get_process (process);
|
|
1363 get_buffer_range_char (buf, start, end, &bstart, &bend, 0);
|
442
|
1364
|
444
|
1365 send_process (process, buffer, 0, bstart, bend - bstart);
|
428
|
1366 return Qnil;
|
|
1367 }
|
|
1368
|
|
1369 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /*
|
|
1370 Send PROCESS the contents of STRING as input.
|
444
|
1371 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1372 name of a buffer, in which case the buffer's process is used. If it
|
|
1373 is nil, the current buffer's process is used.
|
|
1374 Optional arguments START and END specify part of STRING; see `substring'.
|
|
1375 If STRING is more than 100 or so characters long, it may be sent in
|
|
1376 several chunks. This may happen even for shorter strings. Output
|
|
1377 from processes can arrive in between chunks.
|
428
|
1378 */
|
444
|
1379 (process, string, start, end))
|
428
|
1380 {
|
|
1381 /* This function can GC */
|
444
|
1382 Bytecount bstart, bend;
|
428
|
1383
|
444
|
1384 process = get_process (process);
|
428
|
1385 CHECK_STRING (string);
|
444
|
1386 get_string_range_byte (string, start, end, &bstart, &bend,
|
428
|
1387 GB_HISTORICAL_STRING_BEHAVIOR);
|
|
1388
|
444
|
1389 send_process (process, string, 0, bstart, bend - bstart);
|
428
|
1390 return Qnil;
|
|
1391 }
|
|
1392
|
|
1393
|
|
1394 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /*
|
|
1395 Return PROCESS's input coding system.
|
|
1396 */
|
|
1397 (process))
|
|
1398 {
|
|
1399 process = get_process (process);
|
440
|
1400 CHECK_LIVE_PROCESS (process);
|
771
|
1401 return (coding_stream_detected_coding_system
|
|
1402 (XLSTREAM (XPROCESS (process)->coding_instream)));
|
428
|
1403 }
|
|
1404
|
|
1405 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /*
|
|
1406 Return PROCESS's output coding system.
|
|
1407 */
|
|
1408 (process))
|
|
1409 {
|
|
1410 process = get_process (process);
|
440
|
1411 CHECK_LIVE_PROCESS (process);
|
771
|
1412 return (coding_stream_coding_system
|
|
1413 (XLSTREAM (XPROCESS (process)->coding_outstream)));
|
428
|
1414 }
|
|
1415
|
|
1416 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /*
|
|
1417 Return a pair of coding-system for decoding and encoding of PROCESS.
|
|
1418 */
|
|
1419 (process))
|
|
1420 {
|
|
1421 process = get_process (process);
|
440
|
1422 CHECK_LIVE_PROCESS (process);
|
771
|
1423 return Fcons (coding_stream_detected_coding_system
|
428
|
1424 (XLSTREAM (XPROCESS (process)->coding_instream)),
|
771
|
1425 coding_stream_coding_system
|
428
|
1426 (XLSTREAM (XPROCESS (process)->coding_outstream)));
|
|
1427 }
|
|
1428
|
|
1429 DEFUN ("set-process-input-coding-system", Fset_process_input_coding_system,
|
|
1430 2, 2, 0, /*
|
|
1431 Set PROCESS's input coding system to CODESYS.
|
771
|
1432 This is used for reading data from PROCESS.
|
428
|
1433 */
|
|
1434 (process, codesys))
|
|
1435 {
|
771
|
1436 codesys = get_coding_system_for_text_file (codesys, 1);
|
428
|
1437 process = get_process (process);
|
440
|
1438 CHECK_LIVE_PROCESS (process);
|
|
1439
|
771
|
1440 set_coding_stream_coding_system
|
428
|
1441 (XLSTREAM (XPROCESS (process)->coding_instream), codesys);
|
|
1442 return Qnil;
|
|
1443 }
|
|
1444
|
|
1445 DEFUN ("set-process-output-coding-system", Fset_process_output_coding_system,
|
|
1446 2, 2, 0, /*
|
|
1447 Set PROCESS's output coding system to CODESYS.
|
771
|
1448 This is used for writing data to PROCESS.
|
428
|
1449 */
|
|
1450 (process, codesys))
|
|
1451 {
|
771
|
1452 codesys = get_coding_system_for_text_file (codesys, 0);
|
428
|
1453 process = get_process (process);
|
440
|
1454 CHECK_LIVE_PROCESS (process);
|
|
1455
|
771
|
1456 set_coding_stream_coding_system
|
428
|
1457 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys);
|
|
1458 return Qnil;
|
|
1459 }
|
|
1460
|
|
1461 DEFUN ("set-process-coding-system", Fset_process_coding_system,
|
|
1462 1, 3, 0, /*
|
|
1463 Set coding-systems of PROCESS to DECODING and ENCODING.
|
440
|
1464 DECODING will be used to decode subprocess output and ENCODING to
|
|
1465 encode subprocess input.
|
428
|
1466 */
|
|
1467 (process, decoding, encoding))
|
|
1468 {
|
|
1469 if (!NILP (decoding))
|
|
1470 Fset_process_input_coding_system (process, decoding);
|
|
1471
|
|
1472 if (!NILP (encoding))
|
|
1473 Fset_process_output_coding_system (process, encoding);
|
|
1474
|
|
1475 return Qnil;
|
|
1476 }
|
|
1477
|
|
1478
|
|
1479 /************************************************************************/
|
|
1480 /* process status */
|
|
1481 /************************************************************************/
|
|
1482
|
|
1483 static Lisp_Object
|
|
1484 exec_sentinel_unwind (Lisp_Object datum)
|
|
1485 {
|
853
|
1486 XPROCESS (XCAR (datum))->sentinel = XCDR (datum);
|
|
1487 free_cons (datum);
|
428
|
1488 return Qnil;
|
|
1489 }
|
|
1490
|
|
1491 static void
|
444
|
1492 exec_sentinel (Lisp_Object process, Lisp_Object reason)
|
428
|
1493 {
|
|
1494 /* This function can GC */
|
|
1495 int speccount = specpdl_depth ();
|
444
|
1496 Lisp_Process *p = XPROCESS (process);
|
428
|
1497 Lisp_Object sentinel = p->sentinel;
|
|
1498
|
|
1499 if (NILP (sentinel))
|
|
1500 return;
|
|
1501
|
|
1502 /* Some weird FSFmacs crap here with
|
|
1503 Vdeactivate_mark and current_buffer->keymap */
|
|
1504
|
853
|
1505 /* Some FSF junk with running_asynch_code, to preserve the match
|
|
1506 data. Not necessary because we don't call process filters
|
|
1507 asynchronously (i.e. from within QUIT). */
|
|
1508
|
428
|
1509 /* Zilch the sentinel while it's running, to avoid recursive invocations;
|
853
|
1510 assure that it gets restored no matter how the sentinel exits.
|
|
1511
|
|
1512 (#### Why is this necessary? Probably another relic of asynchronous
|
|
1513 calling of process filters/sentinels.) */
|
428
|
1514 p->sentinel = Qnil;
|
853
|
1515 record_unwind_protect (exec_sentinel_unwind,
|
|
1516 noseeum_cons (process, sentinel));
|
|
1517 /* Don't catch errors here; we're not in any critical code. */
|
|
1518 call2 (sentinel, process, reason);
|
771
|
1519 unbind_to (speccount);
|
428
|
1520 }
|
|
1521
|
|
1522 DEFUN ("set-process-sentinel", Fset_process_sentinel, 2, 2, 0, /*
|
|
1523 Give PROCESS the sentinel SENTINEL; nil for none.
|
|
1524 The sentinel is called as a function when the process changes state.
|
|
1525 It gets two arguments: the process, and a string describing the change.
|
|
1526 */
|
444
|
1527 (process, sentinel))
|
428
|
1528 {
|
444
|
1529 CHECK_PROCESS (process);
|
|
1530 XPROCESS (process)->sentinel = sentinel;
|
428
|
1531 return sentinel;
|
|
1532 }
|
|
1533
|
|
1534 DEFUN ("process-sentinel", Fprocess_sentinel, 1, 1, 0, /*
|
|
1535 Return the sentinel of PROCESS; nil if none.
|
|
1536 See `set-process-sentinel' for more info on sentinels.
|
|
1537 */
|
444
|
1538 (process))
|
428
|
1539 {
|
444
|
1540 CHECK_PROCESS (process);
|
|
1541 return XPROCESS (process)->sentinel;
|
428
|
1542 }
|
|
1543
|
|
1544
|
442
|
1545 const char *
|
428
|
1546 signal_name (int signum)
|
|
1547 {
|
|
1548 if (signum >= 0 && signum < NSIG)
|
442
|
1549 return (const char *) sys_siglist[signum];
|
428
|
1550
|
442
|
1551 return (const char *) GETTEXT ("unknown signal");
|
428
|
1552 }
|
|
1553
|
|
1554 void
|
|
1555 update_process_status (Lisp_Object p,
|
|
1556 Lisp_Object status_symbol,
|
|
1557 int exit_code,
|
|
1558 int core_dumped)
|
|
1559 {
|
|
1560 XPROCESS (p)->tick++;
|
|
1561 process_tick++;
|
|
1562 XPROCESS (p)->status_symbol = status_symbol;
|
|
1563 XPROCESS (p)->exit_code = exit_code;
|
|
1564 XPROCESS (p)->core_dumped = core_dumped;
|
|
1565 }
|
|
1566
|
|
1567 /* Return a string describing a process status list. */
|
|
1568
|
|
1569 static Lisp_Object
|
440
|
1570 status_message (Lisp_Process *p)
|
428
|
1571 {
|
|
1572 Lisp_Object symbol = p->status_symbol;
|
|
1573 int code = p->exit_code;
|
|
1574 int coredump = p->core_dumped;
|
|
1575 Lisp_Object string, string2;
|
|
1576
|
|
1577 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop))
|
|
1578 {
|
|
1579 string = build_string (signal_name (code));
|
|
1580 if (coredump)
|
771
|
1581 string2 = build_msg_string (" (core dumped)\n");
|
428
|
1582 else
|
|
1583 string2 = build_string ("\n");
|
793
|
1584 set_string_char (string, 0,
|
826
|
1585 DOWNCASE (0, string_emchar (string, 0)));
|
428
|
1586 return concat2 (string, string2);
|
|
1587 }
|
|
1588 else if (EQ (symbol, Qexit))
|
|
1589 {
|
|
1590 if (code == 0)
|
771
|
1591 return build_msg_string ("finished\n");
|
428
|
1592 string = Fnumber_to_string (make_int (code));
|
|
1593 if (coredump)
|
771
|
1594 string2 = build_msg_string (" (core dumped)\n");
|
428
|
1595 else
|
|
1596 string2 = build_string ("\n");
|
771
|
1597 return concat2 (build_msg_string ("exited abnormally with code "),
|
428
|
1598 concat2 (string, string2));
|
|
1599 }
|
|
1600 else
|
|
1601 return Fcopy_sequence (Fsymbol_name (symbol));
|
|
1602 }
|
|
1603
|
|
1604 /* Tell status_notify() to check for terminated processes. We do this
|
|
1605 because on some systems we sometimes miss SIGCHLD calls. (Not sure
|
853
|
1606 why.) This is also used under Mswin. */
|
428
|
1607
|
|
1608 void
|
|
1609 kick_status_notify (void)
|
|
1610 {
|
|
1611 process_tick++;
|
|
1612 }
|
|
1613
|
|
1614
|
|
1615 /* Report all recent events of a change in process status
|
|
1616 (either run the sentinel or output a message).
|
|
1617 This is done while Emacs is waiting for keyboard input. */
|
|
1618
|
|
1619 void
|
|
1620 status_notify (void)
|
|
1621 {
|
|
1622 /* This function can GC */
|
|
1623 Lisp_Object tail = Qnil;
|
|
1624 Lisp_Object symbol = Qnil;
|
|
1625 Lisp_Object msg = Qnil;
|
|
1626 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1627 /* process_tick is volatile, so we have to remember it now.
|
444
|
1628 Otherwise, we get a race condition if SIGCHLD happens during
|
428
|
1629 this function.
|
|
1630
|
|
1631 (Actually, this is not the case anymore. The code to
|
|
1632 update the process structures has been moved out of the
|
|
1633 SIGCHLD handler. But for the moment I'm leaving this
|
|
1634 stuff in -- it can't hurt.) */
|
|
1635 int temp_process_tick;
|
|
1636
|
|
1637 MAYBE_PROCMETH (reap_exited_processes, ());
|
|
1638
|
|
1639 temp_process_tick = process_tick;
|
|
1640
|
|
1641 if (update_tick == temp_process_tick)
|
|
1642 return;
|
|
1643
|
|
1644 /* We need to gcpro tail; if read_process_output calls a filter
|
|
1645 which deletes a process and removes the cons to which tail points
|
|
1646 from Vprocess_alist, and then causes a GC, tail is an unprotected
|
|
1647 reference. */
|
|
1648 GCPRO3 (tail, symbol, msg);
|
|
1649
|
|
1650 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail))
|
|
1651 {
|
444
|
1652 Lisp_Object process = XCAR (tail);
|
|
1653 Lisp_Process *p = XPROCESS (process);
|
428
|
1654 /* p->tick is also volatile. Same thing as above applies. */
|
|
1655 int this_process_tick;
|
|
1656
|
|
1657 /* #### extra check for terminated processes, in case a SIGCHLD
|
|
1658 got missed (this seems to happen sometimes, I'm not sure why).
|
|
1659 */
|
|
1660 if (INTP (p->pid))
|
|
1661 MAYBE_PROCMETH (update_status_if_terminated, (p));
|
|
1662
|
|
1663 this_process_tick = p->tick;
|
|
1664 if (this_process_tick != p->update_tick)
|
|
1665 {
|
|
1666 p->update_tick = this_process_tick;
|
|
1667
|
|
1668 /* If process is still active, read any output that remains. */
|
|
1669 while (!EQ (p->filter, Qt)
|
853
|
1670 && read_process_output (process, 0) > 0)
|
|
1671 ;
|
|
1672 while (p->separate_stderr && !EQ (p->stderr_filter, Qt)
|
|
1673 && read_process_output (process, 1) > 0)
|
428
|
1674 ;
|
|
1675
|
|
1676 /* Get the text to use for the message. */
|
|
1677 msg = status_message (p);
|
|
1678
|
|
1679 /* If process is terminated, deactivate it or delete it. */
|
|
1680 symbol = p->status_symbol;
|
|
1681
|
|
1682 if (EQ (symbol, Qsignal)
|
|
1683 || EQ (symbol, Qexit))
|
|
1684 {
|
|
1685 if (delete_exited_processes)
|
444
|
1686 remove_process (process);
|
428
|
1687 else
|
444
|
1688 deactivate_process (process);
|
428
|
1689 }
|
|
1690
|
|
1691 /* Now output the message suitably. */
|
|
1692 if (!NILP (p->sentinel))
|
444
|
1693 exec_sentinel (process, msg);
|
428
|
1694 /* Don't bother with a message in the buffer
|
|
1695 when a process becomes runnable. */
|
844
|
1696 else if (!EQ (symbol, Qrun) && !NILP (p->buffer) &&
|
|
1697 /* Avoid error if buffer is deleted
|
|
1698 (probably that's why the process is dead, too) */
|
|
1699 BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
428
|
1700 {
|
844
|
1701 struct gcpro ngcpro1;
|
853
|
1702 int spec = process_setup_for_insertion (process, 0);
|
428
|
1703
|
844
|
1704 NGCPRO1 (process);
|
428
|
1705 buffer_insert_c_string (current_buffer, "\nProcess ");
|
|
1706 Finsert (1, &p->name);
|
|
1707 buffer_insert_c_string (current_buffer, " ");
|
|
1708 Finsert (1, &msg);
|
|
1709 Fset_marker (p->mark, make_int (BUF_PT (current_buffer)),
|
|
1710 p->buffer);
|
|
1711
|
844
|
1712 unbind_to (spec);
|
428
|
1713 NUNGCPRO;
|
|
1714 }
|
|
1715 }
|
|
1716 } /* end for */
|
|
1717
|
|
1718 /* in case buffers use %s in modeline-format */
|
|
1719 MARK_MODELINE_CHANGED;
|
|
1720 redisplay ();
|
|
1721
|
|
1722 update_tick = temp_process_tick;
|
|
1723
|
|
1724 UNGCPRO;
|
|
1725 }
|
|
1726
|
|
1727 DEFUN ("process-status", Fprocess_status, 1, 1, 0, /*
|
|
1728 Return the status of PROCESS.
|
|
1729 This is a symbol, one of these:
|
|
1730
|
|
1731 run -- for a process that is running.
|
|
1732 stop -- for a process stopped but continuable.
|
|
1733 exit -- for a process that has exited.
|
|
1734 signal -- for a process that has got a fatal signal.
|
|
1735 open -- for a network stream connection that is open.
|
|
1736 closed -- for a network stream connection that is closed.
|
|
1737 nil -- if arg is a process name and no such process exists.
|
|
1738
|
|
1739 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1740 nil, indicating the current buffer's process.
|
|
1741 */
|
444
|
1742 (process))
|
428
|
1743 {
|
|
1744 Lisp_Object status_symbol;
|
|
1745
|
444
|
1746 if (STRINGP (process))
|
|
1747 process = Fget_process (process);
|
428
|
1748 else
|
444
|
1749 process = get_process (process);
|
428
|
1750
|
444
|
1751 if (NILP (process))
|
428
|
1752 return Qnil;
|
|
1753
|
444
|
1754 status_symbol = XPROCESS (process)->status_symbol;
|
|
1755 if (network_connection_p (process))
|
428
|
1756 {
|
|
1757 if (EQ (status_symbol, Qrun))
|
|
1758 status_symbol = Qopen;
|
|
1759 else if (EQ (status_symbol, Qexit))
|
|
1760 status_symbol = Qclosed;
|
|
1761 }
|
|
1762 return status_symbol;
|
|
1763 }
|
|
1764
|
|
1765 DEFUN ("process-exit-status", Fprocess_exit_status, 1, 1, 0, /*
|
|
1766 Return the exit status of PROCESS or the signal number that killed it.
|
|
1767 If PROCESS has not yet exited or died, return 0.
|
|
1768 */
|
444
|
1769 (process))
|
428
|
1770 {
|
444
|
1771 CHECK_PROCESS (process);
|
|
1772 return make_int (XPROCESS (process)->exit_code);
|
428
|
1773 }
|
|
1774
|
|
1775
|
|
1776
|
442
|
1777 static int
|
|
1778 decode_signal (Lisp_Object signal_)
|
428
|
1779 {
|
442
|
1780 if (INTP (signal_))
|
|
1781 return XINT (signal_);
|
428
|
1782 else
|
|
1783 {
|
665
|
1784 Intbyte *name;
|
428
|
1785
|
442
|
1786 CHECK_SYMBOL (signal_);
|
793
|
1787 name = XSTRING_DATA (XSYMBOL (signal_)->name);
|
428
|
1788
|
793
|
1789 #define handle_signal(sym) do { \
|
|
1790 if (!qxestrcmp_c ( name, #sym)) \
|
|
1791 return sym; \
|
442
|
1792 } while (0)
|
428
|
1793
|
|
1794 handle_signal (SIGINT); /* ANSI */
|
|
1795 handle_signal (SIGILL); /* ANSI */
|
|
1796 handle_signal (SIGABRT); /* ANSI */
|
|
1797 handle_signal (SIGFPE); /* ANSI */
|
|
1798 handle_signal (SIGSEGV); /* ANSI */
|
|
1799 handle_signal (SIGTERM); /* ANSI */
|
|
1800
|
|
1801 #ifdef SIGHUP
|
|
1802 handle_signal (SIGHUP); /* POSIX */
|
|
1803 #endif
|
|
1804 #ifdef SIGQUIT
|
|
1805 handle_signal (SIGQUIT); /* POSIX */
|
|
1806 #endif
|
|
1807 #ifdef SIGTRAP
|
|
1808 handle_signal (SIGTRAP); /* POSIX */
|
|
1809 #endif
|
|
1810 #ifdef SIGKILL
|
|
1811 handle_signal (SIGKILL); /* POSIX */
|
|
1812 #endif
|
|
1813 #ifdef SIGUSR1
|
|
1814 handle_signal (SIGUSR1); /* POSIX */
|
|
1815 #endif
|
|
1816 #ifdef SIGUSR2
|
|
1817 handle_signal (SIGUSR2); /* POSIX */
|
|
1818 #endif
|
|
1819 #ifdef SIGPIPE
|
|
1820 handle_signal (SIGPIPE); /* POSIX */
|
|
1821 #endif
|
|
1822 #ifdef SIGALRM
|
|
1823 handle_signal (SIGALRM); /* POSIX */
|
|
1824 #endif
|
|
1825 #ifdef SIGCHLD
|
|
1826 handle_signal (SIGCHLD); /* POSIX */
|
|
1827 #endif
|
|
1828 #ifdef SIGCONT
|
|
1829 handle_signal (SIGCONT); /* POSIX */
|
|
1830 #endif
|
|
1831 #ifdef SIGSTOP
|
|
1832 handle_signal (SIGSTOP); /* POSIX */
|
|
1833 #endif
|
|
1834 #ifdef SIGTSTP
|
|
1835 handle_signal (SIGTSTP); /* POSIX */
|
|
1836 #endif
|
|
1837 #ifdef SIGTTIN
|
|
1838 handle_signal (SIGTTIN); /* POSIX */
|
|
1839 #endif
|
|
1840 #ifdef SIGTTOU
|
|
1841 handle_signal (SIGTTOU); /* POSIX */
|
|
1842 #endif
|
|
1843
|
|
1844 #ifdef SIGBUS
|
|
1845 handle_signal (SIGBUS); /* XPG5 */
|
|
1846 #endif
|
|
1847 #ifdef SIGPOLL
|
|
1848 handle_signal (SIGPOLL); /* XPG5 */
|
|
1849 #endif
|
|
1850 #ifdef SIGPROF
|
|
1851 handle_signal (SIGPROF); /* XPG5 */
|
|
1852 #endif
|
|
1853 #ifdef SIGSYS
|
|
1854 handle_signal (SIGSYS); /* XPG5 */
|
|
1855 #endif
|
|
1856 #ifdef SIGURG
|
|
1857 handle_signal (SIGURG); /* XPG5 */
|
|
1858 #endif
|
|
1859 #ifdef SIGXCPU
|
|
1860 handle_signal (SIGXCPU); /* XPG5 */
|
|
1861 #endif
|
|
1862 #ifdef SIGXFSZ
|
|
1863 handle_signal (SIGXFSZ); /* XPG5 */
|
|
1864 #endif
|
|
1865 #ifdef SIGVTALRM
|
|
1866 handle_signal (SIGVTALRM); /* XPG5 */
|
|
1867 #endif
|
|
1868
|
|
1869 #ifdef SIGIO
|
|
1870 handle_signal (SIGIO); /* BSD 4.2 */
|
|
1871 #endif
|
|
1872 #ifdef SIGWINCH
|
|
1873 handle_signal (SIGWINCH); /* BSD 4.3 */
|
|
1874 #endif
|
|
1875
|
|
1876 #ifdef SIGEMT
|
|
1877 handle_signal (SIGEMT);
|
|
1878 #endif
|
|
1879 #ifdef SIGINFO
|
|
1880 handle_signal (SIGINFO);
|
|
1881 #endif
|
|
1882 #ifdef SIGHWE
|
|
1883 handle_signal (SIGHWE);
|
|
1884 #endif
|
|
1885 #ifdef SIGPRE
|
|
1886 handle_signal (SIGPRE);
|
|
1887 #endif
|
|
1888 #ifdef SIGUME
|
|
1889 handle_signal (SIGUME);
|
|
1890 #endif
|
|
1891 #ifdef SIGDLK
|
|
1892 handle_signal (SIGDLK);
|
|
1893 #endif
|
|
1894 #ifdef SIGCPULIM
|
|
1895 handle_signal (SIGCPULIM);
|
|
1896 #endif
|
|
1897 #ifdef SIGIOT
|
|
1898 handle_signal (SIGIOT);
|
|
1899 #endif
|
|
1900 #ifdef SIGLOST
|
|
1901 handle_signal (SIGLOST);
|
|
1902 #endif
|
|
1903 #ifdef SIGSTKFLT
|
|
1904 handle_signal (SIGSTKFLT);
|
|
1905 #endif
|
|
1906 #ifdef SIGUNUSED
|
|
1907 handle_signal (SIGUNUSED);
|
|
1908 #endif
|
|
1909 #ifdef SIGDANGER
|
|
1910 handle_signal (SIGDANGER); /* AIX */
|
|
1911 #endif
|
|
1912 #ifdef SIGMSG
|
|
1913 handle_signal (SIGMSG);
|
|
1914 #endif
|
|
1915 #ifdef SIGSOUND
|
|
1916 handle_signal (SIGSOUND);
|
|
1917 #endif
|
|
1918 #ifdef SIGRETRACT
|
|
1919 handle_signal (SIGRETRACT);
|
|
1920 #endif
|
|
1921 #ifdef SIGGRANT
|
|
1922 handle_signal (SIGGRANT);
|
|
1923 #endif
|
|
1924 #ifdef SIGPWR
|
|
1925 handle_signal (SIGPWR);
|
|
1926 #endif
|
|
1927
|
|
1928 #undef handle_signal
|
|
1929
|
563
|
1930 invalid_constant ("Undefined signal name", signal_);
|
801
|
1931 RETURN_NOT_REACHED (0)
|
442
|
1932 }
|
|
1933 }
|
|
1934
|
|
1935 /* Send signal number SIGNO to PROCESS.
|
|
1936 CURRENT-GROUP non-nil means send signal to the current
|
|
1937 foreground process group of the process's controlling terminal rather
|
|
1938 than to the process's own process group.
|
|
1939 This is used for various commands in shell mode.
|
|
1940 If NOMSG is zero, insert signal-announcements into process's buffers
|
|
1941 right away.
|
|
1942
|
|
1943 If we can, we try to signal PROCESS by sending control characters
|
|
1944 down the pty. This allows us to signal inferiors who have changed
|
|
1945 their uid, for which kill() would return an EPERM error, or to
|
|
1946 processes running on another computer through a remote login. */
|
|
1947
|
|
1948 static void
|
|
1949 process_send_signal (Lisp_Object process, int signo,
|
|
1950 int current_group, int nomsg)
|
|
1951 {
|
|
1952 /* This function can GC */
|
444
|
1953 process = get_process (process);
|
442
|
1954
|
444
|
1955 if (network_connection_p (process))
|
563
|
1956 invalid_operation ("Network connection is not a subprocess", process);
|
444
|
1957 CHECK_LIVE_PROCESS (process);
|
442
|
1958
|
444
|
1959 MAYBE_PROCMETH (kill_child_process, (process, signo, current_group, nomsg));
|
442
|
1960 }
|
|
1961
|
|
1962 DEFUN ("process-send-signal", Fprocess_send_signal, 1, 3, 0, /*
|
|
1963 Send signal SIGNAL to process PROCESS.
|
|
1964 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
1965 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1966 nil, indicating the current buffer's process.
|
|
1967 Third arg CURRENT-GROUP non-nil means send signal to the current
|
|
1968 foreground process group of the process's controlling terminal rather
|
|
1969 than to the process's own process group.
|
|
1970 If the process is a shell that supports job control, this means
|
|
1971 send the signal to the current subjob rather than the shell.
|
|
1972 */
|
|
1973 (signal_, process, current_group))
|
|
1974 {
|
|
1975 /* This function can GC */
|
|
1976 process_send_signal (process, decode_signal (signal_),
|
|
1977 !NILP (current_group), 0);
|
|
1978 return process;
|
|
1979 }
|
|
1980
|
|
1981 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /*
|
|
1982 Interrupt process PROCESS.
|
|
1983 See function `process-send-signal' for more details on usage.
|
|
1984 */
|
|
1985 (process, current_group))
|
|
1986 {
|
|
1987 /* This function can GC */
|
|
1988 process_send_signal (process, SIGINT, !NILP (current_group), 0);
|
|
1989 return process;
|
|
1990 }
|
|
1991
|
|
1992 DEFUN ("kill-process", Fkill_process, 0, 2, 0, /*
|
|
1993 Kill process PROCESS.
|
|
1994 See function `process-send-signal' for more details on usage.
|
|
1995 */
|
|
1996 (process, current_group))
|
|
1997 {
|
|
1998 /* This function can GC */
|
|
1999 #ifdef SIGKILL
|
|
2000 process_send_signal (process, SIGKILL, !NILP (current_group), 0);
|
|
2001 #else
|
563
|
2002 signal_error (Qunimplemented,
|
|
2003 "kill-process: Not supported on this system",
|
|
2004 Qunbound);
|
442
|
2005 #endif
|
|
2006 return process;
|
|
2007 }
|
|
2008
|
|
2009 DEFUN ("quit-process", Fquit_process, 0, 2, 0, /*
|
|
2010 Send QUIT signal to process PROCESS.
|
|
2011 See function `process-send-signal' for more details on usage.
|
|
2012 */
|
|
2013 (process, current_group))
|
|
2014 {
|
|
2015 /* This function can GC */
|
|
2016 #ifdef SIGQUIT
|
|
2017 process_send_signal (process, SIGQUIT, !NILP (current_group), 0);
|
|
2018 #else
|
563
|
2019 signal_error (Qunimplemented,
|
|
2020 "quit-process: Not supported on this system",
|
|
2021 Qunbound);
|
442
|
2022 #endif
|
|
2023 return process;
|
|
2024 }
|
|
2025
|
|
2026 DEFUN ("stop-process", Fstop_process, 0, 2, 0, /*
|
|
2027 Stop process PROCESS.
|
|
2028 See function `process-send-signal' for more details on usage.
|
|
2029 */
|
|
2030 (process, current_group))
|
|
2031 {
|
|
2032 /* This function can GC */
|
|
2033 #ifdef SIGTSTP
|
|
2034 process_send_signal (process, SIGTSTP, !NILP (current_group), 0);
|
|
2035 #else
|
563
|
2036 signal_error (Qunimplemented,
|
|
2037 "stop-process: Not supported on this system",
|
|
2038 Qunbound);
|
442
|
2039 #endif
|
|
2040 return process;
|
|
2041 }
|
|
2042
|
|
2043 DEFUN ("continue-process", Fcontinue_process, 0, 2, 0, /*
|
|
2044 Continue process PROCESS.
|
|
2045 See function `process-send-signal' for more details on usage.
|
|
2046 */
|
|
2047 (process, current_group))
|
|
2048 {
|
|
2049 /* This function can GC */
|
|
2050 #ifdef SIGCONT
|
|
2051 process_send_signal (process, SIGCONT, !NILP (current_group), 0);
|
|
2052 #else
|
563
|
2053 signal_error (Qunimplemented,
|
|
2054 "continue-process: Not supported on this system",
|
|
2055 Qunbound);
|
442
|
2056 #endif
|
|
2057 return process;
|
|
2058 }
|
|
2059
|
|
2060 DEFUN ("signal-process", Fsignal_process, 2, 2,
|
|
2061 "nProcess number: \nnSignal code: ", /*
|
|
2062 Send the process with process id PID the signal with code SIGNAL.
|
|
2063 PID must be an integer. The process need not be a child of this Emacs.
|
|
2064 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
2065 */
|
|
2066 (pid, signal_))
|
|
2067 {
|
|
2068 CHECK_INT (pid);
|
|
2069
|
428
|
2070 return make_int (PROCMETH_OR_GIVEN (kill_process_by_pid,
|
442
|
2071 (XINT (pid), decode_signal (signal_)),
|
|
2072 -1));
|
428
|
2073 }
|
|
2074
|
|
2075 DEFUN ("process-send-eof", Fprocess_send_eof, 0, 1, 0, /*
|
|
2076 Make PROCESS see end-of-file in its input.
|
|
2077 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
2078 nil, indicating the current buffer's process.
|
|
2079 If PROCESS is a network connection, or is a process communicating
|
|
2080 through a pipe (as opposed to a pty), then you cannot send any more
|
|
2081 text to PROCESS after you call this function.
|
|
2082 */
|
|
2083 (process))
|
|
2084 {
|
|
2085 /* This function can GC */
|
444
|
2086 process = get_process (process);
|
428
|
2087
|
|
2088 /* Make sure the process is really alive. */
|
444
|
2089 if (! EQ (XPROCESS (process)->status_symbol, Qrun))
|
563
|
2090 invalid_operation ("Process not running", process);
|
428
|
2091
|
444
|
2092 if (!MAYBE_INT_PROCMETH (process_send_eof, (process)))
|
428
|
2093 {
|
444
|
2094 if (!NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
428
|
2095 {
|
853
|
2096 USID humpty, dumpty;
|
444
|
2097 Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process))));
|
853
|
2098 event_stream_delete_io_streams (Qnil,
|
|
2099 XPROCESS (process)->pipe_outstream,
|
|
2100 Qnil, &humpty, &dumpty);
|
444
|
2101 XPROCESS (process)->pipe_outstream = Qnil;
|
|
2102 XPROCESS (process)->coding_outstream = Qnil;
|
428
|
2103 }
|
|
2104 }
|
|
2105
|
|
2106 return process;
|
|
2107 }
|
|
2108
|
|
2109
|
|
2110 /************************************************************************/
|
|
2111 /* deleting a process */
|
|
2112 /************************************************************************/
|
|
2113
|
|
2114 void
|
444
|
2115 deactivate_process (Lisp_Object process)
|
428
|
2116 {
|
444
|
2117 Lisp_Process *p = XPROCESS (process);
|
853
|
2118 USID in_usid, err_usid;
|
428
|
2119
|
|
2120 /* It's possible that we got as far in the process-creation
|
|
2121 process as creating the descriptors but didn't get so
|
|
2122 far as selecting the process for input. In this
|
|
2123 case, p->pid is nil: p->pid is set at the same time that
|
|
2124 the process is selected for input. */
|
|
2125 /* #### The comment does not look correct. event_stream_unselect_process
|
853
|
2126 is guarded by process->*_selected, so this is not a problem. - kkm*/
|
428
|
2127 /* Must call this before setting the streams to nil */
|
853
|
2128 event_stream_unselect_process (p, 1, 1);
|
428
|
2129
|
|
2130 if (!NILP (DATA_OUTSTREAM (p)))
|
|
2131 Lstream_close (XLSTREAM (DATA_OUTSTREAM (p)));
|
|
2132 if (!NILP (DATA_INSTREAM (p)))
|
|
2133 Lstream_close (XLSTREAM (DATA_INSTREAM (p)));
|
853
|
2134 if (!NILP (DATA_ERRSTREAM (p)))
|
|
2135 Lstream_close (XLSTREAM (DATA_ERRSTREAM (p)));
|
428
|
2136
|
|
2137 /* Provide minimal implementation for deactivate_process
|
|
2138 if there's no process-specific one */
|
|
2139 if (HAS_PROCMETH_P (deactivate_process))
|
853
|
2140 PROCMETH (deactivate_process, (p, &in_usid, &err_usid));
|
428
|
2141 else
|
853
|
2142 event_stream_delete_io_streams (p->pipe_instream,
|
|
2143 p->pipe_outstream,
|
|
2144 p->pipe_errstream,
|
|
2145 &in_usid, &err_usid);
|
428
|
2146
|
853
|
2147 if (in_usid != USID_DONTHASH)
|
|
2148 remhash ((const void*)in_usid, usid_to_process);
|
|
2149 if (err_usid != USID_DONTHASH)
|
|
2150 remhash ((const void*)err_usid, usid_to_process);
|
428
|
2151
|
|
2152 p->pipe_instream = Qnil;
|
|
2153 p->pipe_outstream = Qnil;
|
853
|
2154 p->pipe_errstream = Qnil;
|
428
|
2155 p->coding_instream = Qnil;
|
|
2156 p->coding_outstream = Qnil;
|
853
|
2157 p->coding_errstream = Qnil;
|
428
|
2158 }
|
|
2159
|
|
2160 static void
|
444
|
2161 remove_process (Lisp_Object process)
|
428
|
2162 {
|
444
|
2163 Vprocess_list = delq_no_quit (process, Vprocess_list);
|
|
2164 Fset_marker (XPROCESS (process)->mark, Qnil, Qnil);
|
428
|
2165
|
444
|
2166 deactivate_process (process);
|
428
|
2167 }
|
|
2168
|
|
2169 DEFUN ("delete-process", Fdelete_process, 1, 1, 0, /*
|
|
2170 Delete PROCESS: kill it and forget about it immediately.
|
|
2171 PROCESS may be a process or the name of one, or a buffer name.
|
|
2172 */
|
444
|
2173 (process))
|
428
|
2174 {
|
|
2175 /* This function can GC */
|
440
|
2176 Lisp_Process *p;
|
444
|
2177 process = get_process (process);
|
|
2178 p = XPROCESS (process);
|
|
2179 if (network_connection_p (process))
|
428
|
2180 {
|
|
2181 p->status_symbol = Qexit;
|
|
2182 p->exit_code = 0;
|
|
2183 p->core_dumped = 0;
|
|
2184 p->tick++;
|
|
2185 process_tick++;
|
|
2186 }
|
440
|
2187 else if (PROCESS_LIVE_P (p))
|
428
|
2188 {
|
444
|
2189 Fkill_process (process, Qnil);
|
428
|
2190 /* Do this now, since remove_process will make sigchld_handler do nothing. */
|
|
2191 p->status_symbol = Qsignal;
|
|
2192 p->exit_code = SIGKILL;
|
|
2193 p->core_dumped = 0;
|
|
2194 p->tick++;
|
|
2195 process_tick++;
|
|
2196 status_notify ();
|
|
2197 }
|
444
|
2198 remove_process (process);
|
428
|
2199 return Qnil;
|
|
2200 }
|
|
2201
|
|
2202 /* Kill all processes associated with `buffer'.
|
|
2203 If `buffer' is nil, kill all processes */
|
|
2204
|
|
2205 void
|
|
2206 kill_buffer_processes (Lisp_Object buffer)
|
|
2207 {
|
444
|
2208 LIST_LOOP_2 (process, Vprocess_list)
|
|
2209 if ((NILP (buffer) || EQ (XPROCESS (process)->buffer, buffer)))
|
|
2210 {
|
|
2211 if (network_connection_p (process))
|
|
2212 Fdelete_process (process);
|
|
2213 else if (PROCESS_LIVE_P (XPROCESS (process)))
|
|
2214 process_send_signal (process, SIGHUP, 0, 1);
|
|
2215 }
|
428
|
2216 }
|
|
2217
|
|
2218 DEFUN ("process-kill-without-query", Fprocess_kill_without_query, 1, 2, 0, /*
|
|
2219 Say no query needed if PROCESS is running when Emacs is exited.
|
|
2220 Optional second argument if non-nil says to require a query.
|
|
2221 Value is t if a query was formerly required.
|
|
2222 */
|
444
|
2223 (process, require_query_p))
|
428
|
2224 {
|
|
2225 int tem;
|
|
2226
|
444
|
2227 CHECK_PROCESS (process);
|
|
2228 tem = XPROCESS (process)->kill_without_query;
|
|
2229 XPROCESS (process)->kill_without_query = NILP (require_query_p);
|
428
|
2230
|
|
2231 return tem ? Qnil : Qt;
|
|
2232 }
|
|
2233
|
|
2234 DEFUN ("process-kill-without-query-p", Fprocess_kill_without_query_p, 1, 1, 0, /*
|
444
|
2235 Return t if PROCESS will be killed without query when emacs is exited.
|
428
|
2236 */
|
444
|
2237 (process))
|
428
|
2238 {
|
444
|
2239 CHECK_PROCESS (process);
|
|
2240 return XPROCESS (process)->kill_without_query ? Qt : Qnil;
|
428
|
2241 }
|
|
2242
|
|
2243
|
|
2244 #if 0
|
|
2245
|
826
|
2246 DEFUN ("process-connection", Fprocess_connection, 0, 1, 0, /*
|
428
|
2247 Return the connection type of `PROCESS'. This can be nil (pipe),
|
|
2248 t or pty (pty) or stream (socket connection).
|
|
2249 */
|
|
2250 (process))
|
|
2251 {
|
|
2252 return XPROCESS (process)->type;
|
|
2253 }
|
|
2254
|
|
2255 #endif /* 0 */
|
|
2256
|
814
|
2257
|
|
2258 static int
|
|
2259 getenv_internal (const Intbyte *var,
|
|
2260 Bytecount varlen,
|
|
2261 Intbyte **value,
|
|
2262 Bytecount *valuelen)
|
|
2263 {
|
|
2264 Lisp_Object scan;
|
|
2265
|
|
2266 assert (env_initted);
|
|
2267
|
|
2268 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
2269 {
|
|
2270 Lisp_Object entry = XCAR (scan);
|
|
2271
|
|
2272 if (STRINGP (entry)
|
|
2273 && XSTRING_LENGTH (entry) > varlen
|
826
|
2274 && string_byte (entry, varlen) == '='
|
814
|
2275 #ifdef WIN32_NATIVE
|
|
2276 /* NT environment variables are case insensitive. */
|
|
2277 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
|
2278 #else /* not WIN32_NATIVE */
|
|
2279 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
|
2280 #endif /* not WIN32_NATIVE */
|
|
2281 )
|
|
2282 {
|
|
2283 *value = XSTRING_DATA (entry) + (varlen + 1);
|
|
2284 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1);
|
|
2285 return 1;
|
|
2286 }
|
|
2287 }
|
|
2288
|
|
2289 return 0;
|
|
2290 }
|
|
2291
|
|
2292 static void
|
|
2293 putenv_internal (const Intbyte *var,
|
|
2294 Bytecount varlen,
|
|
2295 const Intbyte *value,
|
|
2296 Bytecount valuelen)
|
|
2297 {
|
|
2298 Lisp_Object scan;
|
|
2299
|
|
2300 assert (env_initted);
|
|
2301
|
|
2302 for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
|
|
2303 {
|
|
2304 Lisp_Object entry = XCAR (scan);
|
|
2305
|
|
2306 if (STRINGP (entry)
|
|
2307 && XSTRING_LENGTH (entry) > varlen
|
826
|
2308 && string_byte (entry, varlen) == '='
|
814
|
2309 #ifdef WIN32_NATIVE
|
|
2310 /* NT environment variables are case insensitive. */
|
|
2311 && ! memicmp (XSTRING_DATA (entry), var, varlen)
|
|
2312 #else /* not WIN32_NATIVE */
|
|
2313 && ! memcmp (XSTRING_DATA (entry), var, varlen)
|
|
2314 #endif /* not WIN32_NATIVE */
|
|
2315 )
|
|
2316 {
|
|
2317 XCAR (scan) = concat3 (make_string (var, varlen),
|
|
2318 build_string ("="),
|
|
2319 make_string (value, valuelen));
|
|
2320 return;
|
|
2321 }
|
|
2322 }
|
|
2323
|
|
2324 Vprocess_environment = Fcons (concat3 (make_string (var, varlen),
|
|
2325 build_string ("="),
|
|
2326 make_string (value, valuelen)),
|
|
2327 Vprocess_environment);
|
|
2328 }
|
|
2329
|
|
2330 /* NOTE:
|
|
2331
|
|
2332 FSF has this as a Lisp function, as follows. Generally moving things
|
|
2333 out of C and into Lisp is a good idea, but in this case the Lisp
|
|
2334 function is used so early in the startup sequence that it would be ugly
|
|
2335 to rearrange the early dumped code to accommodate this.
|
854
|
2336
|
814
|
2337 (defun getenv (variable)
|
|
2338 "Get the value of environment variable VARIABLE.
|
|
2339 VARIABLE should be a string. Value is nil if VARIABLE is undefined in
|
|
2340 the environment. Otherwise, value is a string.
|
|
2341
|
|
2342 This function consults the variable `process-environment'
|
|
2343 for its value."
|
|
2344 (interactive (list (read-envvar-name "Get environment variable: " t)))
|
|
2345 (let ((value (getenv-internal variable)))
|
|
2346 (when (interactive-p)
|
|
2347 (message "%s" (if value value "Not set")))
|
|
2348 value))
|
|
2349 */
|
|
2350
|
|
2351 DEFUN ("getenv", Fgetenv, 1, 2, "sEnvironment variable: \np", /*
|
|
2352 Return the value of environment variable VAR, as a string.
|
|
2353 VAR is a string, the name of the variable.
|
|
2354 When invoked interactively, prints the value in the echo area.
|
|
2355 */
|
|
2356 (var, interactivep))
|
|
2357 {
|
|
2358 Intbyte *value;
|
|
2359 Bytecount valuelen;
|
|
2360 Lisp_Object v = Qnil;
|
|
2361 struct gcpro gcpro1;
|
|
2362
|
|
2363 CHECK_STRING (var);
|
|
2364 GCPRO1 (v);
|
|
2365 if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var),
|
|
2366 &value, &valuelen))
|
|
2367 v = make_string (value, valuelen);
|
|
2368 if (!NILP (interactivep))
|
|
2369 {
|
|
2370 if (NILP (v))
|
|
2371 message ("%s not defined in environment", XSTRING_DATA (var));
|
|
2372 else
|
|
2373 /* #### Should use Fprin1_to_string or Fprin1 to handle string
|
|
2374 containing quotes correctly. */
|
|
2375 message ("\"%s\"", value);
|
|
2376 }
|
|
2377 RETURN_UNGCPRO (v);
|
|
2378 }
|
|
2379
|
|
2380 /* A version of getenv that consults Vprocess_environment, easily
|
|
2381 callable from C.
|
|
2382
|
|
2383 (At init time, Vprocess_environment is initialized from the
|
|
2384 environment, stored in the global variable environ. [Note that
|
|
2385 at startup time, `environ' should be the same as the envp parameter
|
|
2386 passed to main(); however, later calls to putenv() may change
|
|
2387 `environ', making the envp parameter inaccurate.] Calls to getenv()
|
|
2388 and putenv() consult and modify `environ'. However, once
|
|
2389 Vprocess_environment is initted, XEmacs C code should *NEVER* call
|
|
2390 getenv() or putenv() directly, because (1) Lisp code that modifies
|
|
2391 the environment only modifies Vprocess_environment, not `environ';
|
|
2392 and (2) Vprocess_environment is in internal format but `environ'
|
|
2393 is in some external format, and getenv()/putenv() are not Mule-
|
|
2394 encapsulated.
|
|
2395
|
|
2396 WARNING: This value points into Lisp string data and thus will become
|
|
2397 invalid after a GC. */
|
|
2398
|
|
2399 Intbyte *
|
|
2400 egetenv (const CIntbyte *var)
|
|
2401 {
|
|
2402 /* This cannot GC -- 7-28-00 ben */
|
|
2403 Intbyte *value;
|
|
2404 Bytecount valuelen;
|
|
2405
|
|
2406 if (getenv_internal ((const Intbyte *) var, strlen (var), &value, &valuelen))
|
|
2407 return value;
|
|
2408 else
|
|
2409 return 0;
|
|
2410 }
|
|
2411
|
|
2412 void
|
|
2413 eputenv (const CIntbyte *var, const CIntbyte *value)
|
|
2414 {
|
|
2415 putenv_internal ((Intbyte *) var, strlen (var), (Intbyte *) value,
|
|
2416 strlen (value));
|
|
2417 }
|
|
2418
|
|
2419
|
|
2420 /* This is not named init_process in order to avoid a conflict with NS 3.3 */
|
|
2421 void
|
|
2422 init_xemacs_process (void)
|
|
2423 {
|
|
2424 /* This function can GC */
|
|
2425
|
|
2426 MAYBE_PROCMETH (init_process, ());
|
|
2427
|
|
2428 Vprocess_list = Qnil;
|
|
2429
|
|
2430 if (usid_to_process)
|
|
2431 clrhash (usid_to_process);
|
|
2432 else
|
|
2433 usid_to_process = make_hash_table (32);
|
854
|
2434
|
814
|
2435 {
|
|
2436 /* jwz: always initialize Vprocess_environment, so that egetenv()
|
|
2437 works in temacs. */
|
|
2438 char **envp;
|
|
2439 Vprocess_environment = Qnil;
|
|
2440 for (envp = environ; envp && *envp; envp++)
|
|
2441 Vprocess_environment =
|
|
2442 Fcons (build_ext_string (*envp, Qnative), Vprocess_environment);
|
|
2443 /* This gets set back to 0 in disksave_object_finalization() */
|
|
2444 env_initted = 1;
|
|
2445 }
|
|
2446
|
|
2447 {
|
|
2448 /* Initialize shell-file-name from environment variables or best guess. */
|
|
2449 #ifdef WIN32_NATIVE
|
|
2450 const Intbyte *shell = egetenv ("SHELL");
|
|
2451 if (!shell) shell = egetenv ("COMSPEC");
|
|
2452 /* Should never happen! */
|
|
2453 if (!shell) shell =
|
|
2454 (Intbyte *) (GetVersion () & 0x80000000 ? "command" : "cmd");
|
|
2455 #else /* not WIN32_NATIVE */
|
|
2456 const Intbyte *shell = egetenv ("SHELL");
|
|
2457 if (!shell) shell = (Intbyte *) "/bin/sh";
|
|
2458 #endif
|
|
2459
|
|
2460 #if 0 /* defined (WIN32_NATIVE) */
|
|
2461 /* BAD BAD BAD. We do not wanting to be passing an XEmacs-created
|
|
2462 SHELL var down to some inferior Cygwin process, which might get
|
|
2463 screwed up.
|
854
|
2464
|
814
|
2465 There are a few broken apps (eterm/term.el, eterm/tshell.el,
|
|
2466 os-utils/terminal.el, texinfo/tex-mode.el) where this will
|
|
2467 cause problems. Those broken apps don't look at
|
|
2468 shell-file-name, instead just at explicit-shell-file-name,
|
|
2469 ESHELL and SHELL. They are apparently attempting to borrow
|
|
2470 what `M-x shell' uses, but that latter also looks at
|
|
2471 shell-file-name. What we want is for all of these apps to look
|
|
2472 at shell-file-name, so that the user can change the value of
|
|
2473 shell-file-name and everything will work out hunky-dorey.
|
|
2474 */
|
854
|
2475
|
814
|
2476 if (!egetenv ("SHELL"))
|
|
2477 {
|
|
2478 Intbyte *faux_var = alloca_array (Intbyte, 7 + qxestrlen (shell));
|
|
2479 qxesprintf (faux_var, "SHELL=%s", shell);
|
|
2480 Vprocess_environment = Fcons (build_intstring (faux_var),
|
|
2481 Vprocess_environment);
|
|
2482 }
|
|
2483 #endif /* 0 */
|
|
2484
|
|
2485 Vshell_file_name = build_intstring (shell);
|
|
2486 }
|
|
2487 }
|
|
2488
|
428
|
2489 void
|
|
2490 syms_of_process (void)
|
|
2491 {
|
442
|
2492 INIT_LRECORD_IMPLEMENTATION (process);
|
|
2493
|
563
|
2494 DEFSYMBOL (Qprocessp);
|
|
2495 DEFSYMBOL (Qprocess_live_p);
|
|
2496 DEFSYMBOL (Qrun);
|
|
2497 DEFSYMBOL (Qstop);
|
|
2498 DEFSYMBOL (Qopen);
|
|
2499 DEFSYMBOL (Qclosed);
|
428
|
2500
|
563
|
2501 DEFSYMBOL (Qtcp);
|
|
2502 DEFSYMBOL (Qudp);
|
428
|
2503
|
|
2504 #ifdef HAVE_MULTICAST
|
563
|
2505 DEFSYMBOL (Qmulticast); /* Used for occasional warnings */
|
428
|
2506 #endif
|
|
2507
|
563
|
2508 DEFERROR_STANDARD (Qprocess_error, Qio_error);
|
|
2509 DEFERROR_STANDARD (Qnetwork_error, Qio_error);
|
|
2510
|
428
|
2511 DEFSUBR (Fprocessp);
|
440
|
2512 DEFSUBR (Fprocess_live_p);
|
428
|
2513 DEFSUBR (Fget_process);
|
|
2514 DEFSUBR (Fget_buffer_process);
|
|
2515 DEFSUBR (Fdelete_process);
|
|
2516 DEFSUBR (Fprocess_status);
|
|
2517 DEFSUBR (Fprocess_exit_status);
|
|
2518 DEFSUBR (Fprocess_id);
|
|
2519 DEFSUBR (Fprocess_name);
|
|
2520 DEFSUBR (Fprocess_tty_name);
|
|
2521 DEFSUBR (Fprocess_command);
|
859
|
2522 DEFSUBR (Fprocess_has_separate_stderr_p);
|
428
|
2523 DEFSUBR (Fset_process_buffer);
|
853
|
2524 DEFSUBR (Fset_process_stderr_buffer);
|
428
|
2525 DEFSUBR (Fprocess_buffer);
|
|
2526 DEFSUBR (Fprocess_mark);
|
853
|
2527 DEFSUBR (Fprocess_stderr_buffer);
|
|
2528 DEFSUBR (Fprocess_stderr_mark);
|
428
|
2529 DEFSUBR (Fset_process_filter);
|
|
2530 DEFSUBR (Fprocess_filter);
|
853
|
2531 DEFSUBR (Fset_process_stderr_filter);
|
|
2532 DEFSUBR (Fprocess_stderr_filter);
|
428
|
2533 DEFSUBR (Fset_process_window_size);
|
|
2534 DEFSUBR (Fset_process_sentinel);
|
|
2535 DEFSUBR (Fprocess_sentinel);
|
|
2536 DEFSUBR (Fprocess_kill_without_query);
|
|
2537 DEFSUBR (Fprocess_kill_without_query_p);
|
|
2538 DEFSUBR (Fprocess_list);
|
|
2539 DEFSUBR (Fstart_process_internal);
|
|
2540 #ifdef HAVE_SOCKETS
|
|
2541 DEFSUBR (Fopen_network_stream_internal);
|
|
2542 #ifdef HAVE_MULTICAST
|
|
2543 DEFSUBR (Fopen_multicast_group_internal);
|
|
2544 #endif /* HAVE_MULTICAST */
|
|
2545 #endif /* HAVE_SOCKETS */
|
|
2546 DEFSUBR (Fprocess_send_region);
|
|
2547 DEFSUBR (Fprocess_send_string);
|
442
|
2548 DEFSUBR (Fprocess_send_signal);
|
428
|
2549 DEFSUBR (Finterrupt_process);
|
|
2550 DEFSUBR (Fkill_process);
|
|
2551 DEFSUBR (Fquit_process);
|
|
2552 DEFSUBR (Fstop_process);
|
|
2553 DEFSUBR (Fcontinue_process);
|
|
2554 DEFSUBR (Fprocess_send_eof);
|
|
2555 DEFSUBR (Fsignal_process);
|
|
2556 /* DEFSUBR (Fprocess_connection); */
|
|
2557 DEFSUBR (Fprocess_input_coding_system);
|
|
2558 DEFSUBR (Fprocess_output_coding_system);
|
|
2559 DEFSUBR (Fset_process_input_coding_system);
|
|
2560 DEFSUBR (Fset_process_output_coding_system);
|
|
2561 DEFSUBR (Fprocess_coding_system);
|
|
2562 DEFSUBR (Fset_process_coding_system);
|
814
|
2563 DEFSUBR (Fgetenv);
|
428
|
2564 }
|
|
2565
|
|
2566 void
|
|
2567 vars_of_process (void)
|
|
2568 {
|
|
2569 Fprovide (intern ("subprocesses"));
|
|
2570 #ifdef HAVE_SOCKETS
|
|
2571 Fprovide (intern ("network-streams"));
|
|
2572 #ifdef HAVE_MULTICAST
|
|
2573 Fprovide (intern ("multicast"));
|
|
2574 #endif /* HAVE_MULTICAST */
|
|
2575 #endif /* HAVE_SOCKETS */
|
|
2576 staticpro (&Vprocess_list);
|
|
2577
|
|
2578 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes /*
|
|
2579 *Non-nil means delete processes immediately when they exit.
|
|
2580 nil means don't delete them until `list-processes' is run.
|
|
2581 */ );
|
|
2582
|
|
2583 delete_exited_processes = 1;
|
|
2584
|
442
|
2585 DEFVAR_CONST_LISP ("null-device", &Vnull_device /*
|
|
2586 Name of the null device, which differs from system to system.
|
|
2587 The null device is a filename that acts as a sink for arbitrary amounts of
|
|
2588 data, which is discarded, or as a source for a zero-length file.
|
|
2589 It is available on all the systems that we currently support, but with
|
|
2590 different names (typically either `/dev/null' or `nul').
|
|
2591
|
|
2592 Note that there is also a /dev/zero on most modern Unix versions (including
|
|
2593 Cygwin), which acts like /dev/null when used as a sink, but as a source
|
|
2594 it sends a non-ending stream of zero bytes. It's used most often along
|
|
2595 with memory-mapping. We don't provide a Lisp variable for this because
|
|
2596 the operations needing this are lower level than what ELisp programs
|
|
2597 typically do, and in any case no equivalent exists under native MS Windows.
|
|
2598 */ );
|
|
2599 Vnull_device = build_string (NULL_DEVICE);
|
|
2600
|
428
|
2601 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /*
|
|
2602 Control type of device used to communicate with subprocesses.
|
|
2603 Values are nil to use a pipe, or t or `pty' to use a pty.
|
|
2604 The value has no effect if the system has no ptys or if all ptys are busy:
|
|
2605 then a pipe is used in any case.
|
|
2606 The value takes effect when `start-process' is called.
|
|
2607 */ );
|
|
2608 Vprocess_connection_type = Qt;
|
|
2609
|
|
2610 DEFVAR_BOOL ("windowed-process-io", &windowed_process_io /*
|
|
2611 Enables input/output on standard handles of a windowed process.
|
|
2612 When this variable is nil (the default), XEmacs does not attempt to read
|
|
2613 standard output handle of a windowed process. Instead, the process is
|
|
2614 immediately marked as exited immediately upon successful launching. This is
|
|
2615 done because normal windowed processes do not use standard I/O, as they are
|
|
2616 not connected to any console.
|
|
2617
|
|
2618 When launching a specially crafted windowed process, which expects to be
|
|
2619 launched by XEmacs, or by other program which pipes its standard input and
|
|
2620 output, this variable must be set to non-nil, in which case XEmacs will
|
|
2621 treat this process just like a console process.
|
|
2622
|
|
2623 NOTE: You should never set this variable, only bind it.
|
|
2624
|
|
2625 Only Windows processes can be "windowed" or "console". This variable has no
|
|
2626 effect on UNIX processes, because all UNIX processes are "console".
|
|
2627 */ );
|
|
2628 windowed_process_io = 0;
|
|
2629
|
771
|
2630 DEFVAR_INT ("debug-process-io", &debug_process_io /*
|
|
2631 If non-zero, display data sent to or received from a process.
|
|
2632 */ );
|
|
2633 debug_process_io = 0;
|
|
2634
|
|
2635 DEFVAR_LISP ("default-process-coding-system",
|
|
2636 &Vdefault_process_coding_system /*
|
|
2637 Cons of coding systems used for process I/O by default.
|
|
2638 The car part is used for reading (decoding) data from a process, and
|
|
2639 the cdr part is used for writing (encoding) data to a process.
|
|
2640 */ );
|
|
2641 /* This below will get its default set correctly in code-init.el. */
|
|
2642 Vdefault_process_coding_system = Fcons (Qundecided, Qnil);
|
|
2643
|
853
|
2644 DEFVAR_LISP ("default-network-coding-system",
|
|
2645 &Vdefault_network_coding_system /*
|
|
2646 Cons of coding systems used for network I/O by default.
|
|
2647 The car part is used for reading (decoding) data from a process, and
|
|
2648 the cdr part is used for writing (encoding) data to a process.
|
|
2649 */ );
|
|
2650 Vdefault_network_coding_system = Fcons (Qundecided, Qnil);
|
|
2651
|
428
|
2652 #ifdef PROCESS_IO_BLOCKING
|
|
2653 DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /*
|
|
2654 List of port numbers or port names to set a blocking I/O mode with connection.
|
|
2655 Nil value means to set a default(non-blocking) I/O mode.
|
|
2656 The value takes effect when `open-network-stream-internal' is called.
|
|
2657 */ );
|
|
2658 network_stream_blocking_port_list = Qnil;
|
|
2659 #endif /* PROCESS_IO_BLOCKING */
|
814
|
2660
|
|
2661 /* This function can GC */
|
|
2662 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /*
|
|
2663 *File name to load inferior shells from.
|
|
2664 Initialized from the SHELL environment variable.
|
|
2665 */ );
|
428
|
2666
|
814
|
2667 DEFVAR_LISP ("process-environment", &Vprocess_environment /*
|
|
2668 List of environment variables for subprocesses to inherit.
|
|
2669 Each element should be a string of the form ENVVARNAME=VALUE.
|
|
2670 The environment which Emacs inherits is placed in this variable
|
|
2671 when Emacs starts.
|
|
2672 */ );
|
|
2673
|
|
2674 Vlisp_EXEC_SUFFIXES = build_string (EXEC_SUFFIXES);
|
|
2675 staticpro (&Vlisp_EXEC_SUFFIXES);
|
|
2676 }
|