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