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.
|
|
5 Copyright (C) 1995, 1996 Ben Wing.
|
|
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
|
|
24 /* This file has been Mule-ized except for `start-process-internal',
|
|
25 `open-network-stream-internal' and `open-multicast-group-internal'. */
|
|
26
|
|
27 /* This file has been split into process.c and process-unix.c by
|
|
28 Kirill M. Katsnelson <kkm@kis.ru>, so please bash him and not
|
|
29 the original author(s) */
|
|
30
|
|
31 #include <config.h>
|
|
32
|
|
33 #if !defined (NO_SUBPROCESSES)
|
|
34
|
|
35 /* The entire file is within this conditional */
|
|
36
|
|
37 #include "lisp.h"
|
|
38
|
|
39 #include "buffer.h"
|
|
40 #include "commands.h"
|
|
41 #include "events.h"
|
|
42 #include "frame.h"
|
|
43 #include "hash.h"
|
|
44 #include "insdel.h"
|
|
45 #include "lstream.h"
|
|
46 #include "opaque.h"
|
|
47 #include "process.h"
|
|
48 #include "procimpl.h"
|
|
49 #include "window.h"
|
|
50 #ifdef FILE_CODING
|
|
51 #include "file-coding.h"
|
|
52 #endif
|
|
53
|
|
54 #include "sysfile.h"
|
|
55 #include "sysproc.h"
|
|
56 #include "systime.h"
|
|
57 #include "syssignal.h" /* Always include before systty.h */
|
|
58 #include "systty.h"
|
|
59 #include "syswait.h"
|
|
60
|
440
|
61 Lisp_Object Qprocessp, Qprocess_live_p;
|
428
|
62
|
|
63 /* Process methods */
|
|
64 struct process_methods the_process_methods;
|
|
65
|
|
66 /* a process object is a network connection when its pid field a cons
|
|
67 (name of name of port we are connected to . foreign host name) */
|
|
68
|
|
69 /* Valid values of process->status_symbol */
|
|
70 Lisp_Object Qrun, Qstop;
|
|
71 /* Qrun => Qopen, Qexit => Qclosed for "network connection" processes */
|
|
72 Lisp_Object Qopen, Qclosed;
|
|
73 /* Protocol families */
|
|
74 Lisp_Object Qtcp, Qudp;
|
|
75
|
|
76 #ifdef HAVE_MULTICAST
|
|
77 Lisp_Object Qmulticast; /* Will be used for occasional warnings */
|
|
78 #endif
|
|
79
|
|
80 /* t means use pty, nil means use a pipe,
|
|
81 maybe other values to come. */
|
|
82 Lisp_Object Vprocess_connection_type;
|
|
83
|
|
84 /* Read comments to DEFVAR of this */
|
|
85 int windowed_process_io;
|
|
86
|
|
87 #ifdef PROCESS_IO_BLOCKING
|
|
88 /* List of port numbers or port names to set a blocking I/O mode.
|
|
89 Nil means set a non-blocking I/O mode [default]. */
|
|
90 Lisp_Object network_stream_blocking_port_list;
|
|
91 #endif /* PROCESS_IO_BLOCKING */
|
|
92
|
|
93 /* Number of events of change of status of a process. */
|
|
94 volatile int process_tick;
|
|
95
|
|
96 /* Number of events for which the user or sentinel has been notified. */
|
|
97 static int update_tick;
|
|
98
|
|
99 /* Nonzero means delete a process right away if it exits. */
|
|
100 int delete_exited_processes;
|
|
101
|
|
102 /* Hash table which maps USIDs as returned by create_stream_pair_cb to
|
|
103 process objects. Processes are not GC-protected through this! */
|
|
104 struct hash_table *usid_to_process;
|
|
105
|
|
106 /* List of process objects. */
|
|
107 Lisp_Object Vprocess_list;
|
|
108
|
|
109 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
|
442
|
110 Lisp_Object Vnull_device;
|
428
|
111
|
563
|
112 Lisp_Object Qprocess_error;
|
|
113 Lisp_Object Qnetwork_error;
|
|
114
|
428
|
115
|
|
116
|
|
117 static Lisp_Object
|
444
|
118 mark_process (Lisp_Object object)
|
428
|
119 {
|
444
|
120 Lisp_Process *process = XPROCESS (object);
|
|
121 MAYBE_PROCMETH (mark_process_data, (process));
|
|
122 mark_object (process->name);
|
|
123 mark_object (process->command);
|
|
124 mark_object (process->filter);
|
|
125 mark_object (process->sentinel);
|
|
126 mark_object (process->buffer);
|
|
127 mark_object (process->mark);
|
|
128 mark_object (process->pid);
|
|
129 mark_object (process->pipe_instream);
|
|
130 mark_object (process->pipe_outstream);
|
428
|
131 #ifdef FILE_CODING
|
444
|
132 mark_object (process->coding_instream);
|
|
133 mark_object (process->coding_outstream);
|
428
|
134 #endif
|
444
|
135 return process->status_symbol;
|
428
|
136 }
|
|
137
|
|
138 static void
|
444
|
139 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag)
|
428
|
140 {
|
444
|
141 Lisp_Process *process = XPROCESS (object);
|
428
|
142
|
|
143 if (print_readably)
|
563
|
144 printing_unreadable_object ("#<process %s>", XSTRING_DATA (process->name));
|
428
|
145
|
|
146 if (!escapeflag)
|
|
147 {
|
444
|
148 print_internal (process->name, printcharfun, 0);
|
428
|
149 }
|
|
150 else
|
|
151 {
|
444
|
152 int netp = network_connection_p (object);
|
428
|
153 write_c_string ((netp ? GETTEXT ("#<network connection ") :
|
|
154 GETTEXT ("#<process ")), printcharfun);
|
444
|
155 print_internal (process->name, printcharfun, 1);
|
428
|
156 write_c_string ((netp ? " " : " pid "), printcharfun);
|
444
|
157 print_internal (process->pid, printcharfun, 1);
|
428
|
158 write_c_string (" state:", printcharfun);
|
444
|
159 print_internal (process->status_symbol, printcharfun, 1);
|
|
160 MAYBE_PROCMETH (print_process_data, (process, printcharfun));
|
428
|
161 write_c_string (">", printcharfun);
|
|
162 }
|
|
163 }
|
|
164
|
|
165 #ifdef HAVE_WINDOW_SYSTEM
|
440
|
166 extern void debug_process_finalization (Lisp_Process *p);
|
428
|
167 #endif /* HAVE_WINDOW_SYSTEM */
|
|
168
|
|
169 static void
|
|
170 finalize_process (void *header, int for_disksave)
|
|
171 {
|
|
172 /* #### this probably needs to be tied into the tty event loop */
|
|
173 /* #### when there is one */
|
440
|
174 Lisp_Process *p = (Lisp_Process *) header;
|
428
|
175 #ifdef HAVE_WINDOW_SYSTEM
|
|
176 if (!for_disksave)
|
|
177 {
|
|
178 debug_process_finalization (p);
|
|
179 }
|
|
180 #endif /* HAVE_WINDOW_SYSTEM */
|
|
181
|
|
182 if (p->process_data)
|
|
183 {
|
|
184 MAYBE_PROCMETH (finalize_process_data, (p, for_disksave));
|
|
185 if (!for_disksave)
|
|
186 xfree (p->process_data);
|
|
187 }
|
|
188 }
|
|
189
|
|
190 DEFINE_LRECORD_IMPLEMENTATION ("process", process,
|
|
191 mark_process, print_process, finalize_process,
|
440
|
192 0, 0, 0, Lisp_Process);
|
428
|
193
|
|
194 /************************************************************************/
|
|
195 /* basic process accessors */
|
|
196 /************************************************************************/
|
|
197
|
|
198 /* Under FILE_CODING, this function returns low-level streams, connected
|
|
199 directly to the child process, rather than en/decoding FILE_CODING
|
|
200 streams */
|
|
201 void
|
440
|
202 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr)
|
428
|
203 {
|
|
204 assert (p);
|
|
205 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream));
|
|
206 assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream));
|
|
207 *instr = p->pipe_instream;
|
|
208 *outstr = p->pipe_outstream;
|
|
209 }
|
|
210
|
440
|
211 Lisp_Process *
|
428
|
212 get_process_from_usid (USID usid)
|
|
213 {
|
442
|
214 const void *vval;
|
428
|
215
|
|
216 assert (usid != USID_ERROR && usid != USID_DONTHASH);
|
|
217
|
442
|
218 if (gethash ((const void*)usid, usid_to_process, &vval))
|
428
|
219 {
|
444
|
220 Lisp_Object process;
|
|
221 CVOID_TO_LISP (process, vval);
|
|
222 return XPROCESS (process);
|
428
|
223 }
|
|
224 else
|
|
225 return 0;
|
|
226 }
|
|
227
|
|
228 int
|
440
|
229 get_process_selected_p (Lisp_Process *p)
|
428
|
230 {
|
|
231 return p->selected;
|
|
232 }
|
|
233
|
|
234 void
|
440
|
235 set_process_selected_p (Lisp_Process *p, int selected_p)
|
428
|
236 {
|
|
237 p->selected = !!selected_p;
|
|
238 }
|
|
239
|
|
240 int
|
440
|
241 connected_via_filedesc_p (Lisp_Process *p)
|
428
|
242 {
|
|
243 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p));
|
|
244 }
|
|
245
|
|
246 #ifdef HAVE_SOCKETS
|
|
247 int
|
|
248 network_connection_p (Lisp_Object process)
|
|
249 {
|
|
250 return CONSP (XPROCESS (process)->pid);
|
|
251 }
|
|
252 #endif
|
|
253
|
|
254 DEFUN ("processp", Fprocessp, 1, 1, 0, /*
|
|
255 Return t if OBJECT is a process.
|
|
256 */
|
444
|
257 (object))
|
428
|
258 {
|
444
|
259 return PROCESSP (object) ? Qt : Qnil;
|
428
|
260 }
|
|
261
|
440
|
262 DEFUN ("process-live-p", Fprocess_live_p, 1, 1, 0, /*
|
|
263 Return t if OBJECT is a process that is alive.
|
|
264 */
|
444
|
265 (object))
|
440
|
266 {
|
444
|
267 return PROCESSP (object) && PROCESS_LIVE_P (XPROCESS (object))
|
|
268 ? Qt : Qnil;
|
440
|
269 }
|
|
270
|
428
|
271 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /*
|
|
272 Return a list of all processes.
|
|
273 */
|
|
274 ())
|
|
275 {
|
|
276 return Fcopy_sequence (Vprocess_list);
|
|
277 }
|
|
278
|
|
279 DEFUN ("get-process", Fget_process, 1, 1, 0, /*
|
444
|
280 Return the process named PROCESS-NAME (a string), or nil if there is none.
|
|
281 PROCESS-NAME may also be a process; if so, the value is that process.
|
428
|
282 */
|
444
|
283 (process_name))
|
428
|
284 {
|
444
|
285 if (PROCESSP (process_name))
|
|
286 return process_name;
|
428
|
287
|
|
288 if (!gc_in_progress)
|
|
289 /* this only gets called during GC when emacs is going away as a result
|
|
290 of a signal or crash. */
|
444
|
291 CHECK_STRING (process_name);
|
428
|
292
|
444
|
293 {
|
|
294 LIST_LOOP_2 (process, Vprocess_list)
|
|
295 if (internal_equal (process_name, XPROCESS (process)->name, 0))
|
|
296 return process;
|
|
297 }
|
428
|
298 return Qnil;
|
|
299 }
|
|
300
|
|
301 DEFUN ("get-buffer-process", Fget_buffer_process, 1, 1, 0, /*
|
|
302 Return the (or, a) process associated with BUFFER.
|
|
303 BUFFER may be a buffer or the name of one.
|
|
304 */
|
444
|
305 (buffer))
|
428
|
306 {
|
444
|
307 if (NILP (buffer)) return Qnil;
|
|
308 buffer = Fget_buffer (buffer);
|
|
309 if (NILP (buffer)) return Qnil;
|
428
|
310
|
444
|
311 {
|
|
312 LIST_LOOP_2 (process, Vprocess_list)
|
|
313 if (EQ (XPROCESS (process)->buffer, buffer))
|
|
314 return process;
|
|
315 }
|
428
|
316 return Qnil;
|
|
317 }
|
|
318
|
|
319 /* This is how commands for the user decode process arguments. It
|
|
320 accepts a process, a process name, a buffer, a buffer name, or nil.
|
|
321 Buffers denote the first process in the buffer, and nil denotes the
|
|
322 current buffer. */
|
|
323
|
|
324 static Lisp_Object
|
|
325 get_process (Lisp_Object name)
|
|
326 {
|
444
|
327 Lisp_Object buffer;
|
428
|
328
|
|
329 #ifdef I18N3
|
|
330 /* #### Look more closely into translating process names. */
|
|
331 #endif
|
|
332
|
|
333 /* This may be called during a GC from process_send_signal() from
|
|
334 kill_buffer_processes() if emacs decides to abort(). */
|
|
335 if (PROCESSP (name))
|
|
336 return name;
|
444
|
337 else if (STRINGP (name))
|
428
|
338 {
|
444
|
339 Lisp_Object object = Fget_process (name);
|
|
340 if (PROCESSP (object))
|
|
341 return object;
|
|
342
|
|
343 buffer = Fget_buffer (name);
|
|
344 if (BUFFERP (buffer))
|
|
345 goto have_buffer_object;
|
|
346
|
563
|
347 invalid_argument ("Process does not exist", name);
|
428
|
348 }
|
|
349 else if (NILP (name))
|
444
|
350 {
|
|
351 buffer = Fcurrent_buffer ();
|
|
352 goto have_buffer_object;
|
|
353 }
|
|
354 else if (BUFFERP (name))
|
|
355 {
|
|
356 Lisp_Object process;
|
|
357 buffer = name;
|
428
|
358
|
444
|
359 have_buffer_object:
|
|
360 process = Fget_buffer_process (buffer);
|
|
361 if (PROCESSP (process))
|
|
362 return process;
|
|
363
|
563
|
364 invalid_argument ("Buffer has no process", buffer);
|
428
|
365 }
|
|
366 else
|
444
|
367 return get_process (Fsignal (Qwrong_type_argument,
|
|
368 (list2 (build_string ("process or buffer or nil"),
|
|
369 name))));
|
428
|
370 }
|
|
371
|
|
372 DEFUN ("process-id", Fprocess_id, 1, 1, 0, /*
|
|
373 Return the process id of PROCESS.
|
|
374 This is the pid of the Unix process which PROCESS uses or talks to.
|
|
375 For a network connection, this value is a cons of
|
|
376 (foreign-network-port . foreign-host-name).
|
|
377 */
|
444
|
378 (process))
|
428
|
379 {
|
|
380 Lisp_Object pid;
|
444
|
381 CHECK_PROCESS (process);
|
428
|
382
|
444
|
383 pid = XPROCESS (process)->pid;
|
|
384 if (network_connection_p (process))
|
428
|
385 /* return Qnil; */
|
|
386 return Fcons (Fcar (pid), Fcdr (pid));
|
|
387 else
|
|
388 return pid;
|
|
389 }
|
|
390
|
|
391 DEFUN ("process-name", Fprocess_name, 1, 1, 0, /*
|
|
392 Return the name of PROCESS, as a string.
|
|
393 This is the name of the program invoked in PROCESS,
|
|
394 possibly modified to make it unique among process names.
|
|
395 */
|
444
|
396 (process))
|
428
|
397 {
|
444
|
398 CHECK_PROCESS (process);
|
|
399 return XPROCESS (process)->name;
|
428
|
400 }
|
|
401
|
|
402 DEFUN ("process-command", Fprocess_command, 1, 1, 0, /*
|
|
403 Return the command that was executed to start PROCESS.
|
|
404 This is a list of strings, the first string being the program executed
|
|
405 and the rest of the strings being the arguments given to it.
|
|
406 */
|
444
|
407 (process))
|
428
|
408 {
|
444
|
409 CHECK_PROCESS (process);
|
|
410 return XPROCESS (process)->command;
|
428
|
411 }
|
|
412
|
|
413
|
|
414 /************************************************************************/
|
|
415 /* creating a process */
|
|
416 /************************************************************************/
|
|
417
|
563
|
418 DOESNT_RETURN
|
|
419 report_process_error (const char *string, Lisp_Object data)
|
|
420 {
|
|
421 report_error_with_errno (Qprocess_error, string, data);
|
|
422 }
|
|
423
|
|
424 DOESNT_RETURN
|
|
425 report_network_error (const char *string, Lisp_Object data)
|
|
426 {
|
|
427 report_error_with_errno (Qnetwork_error, string, data);
|
|
428 }
|
|
429
|
428
|
430 Lisp_Object
|
|
431 make_process_internal (Lisp_Object name)
|
|
432 {
|
|
433 Lisp_Object val, name1;
|
|
434 int i;
|
440
|
435 Lisp_Process *p = alloc_lcrecord_type (Lisp_Process, &lrecord_process);
|
428
|
436
|
|
437 /* If name is already in use, modify it until it is unused. */
|
|
438 name1 = name;
|
|
439 for (i = 1; ; i++)
|
|
440 {
|
|
441 char suffix[10];
|
|
442 Lisp_Object tem = Fget_process (name1);
|
|
443 if (NILP (tem))
|
|
444 break;
|
|
445 sprintf (suffix, "<%d>", i);
|
|
446 name1 = concat2 (name, build_string (suffix));
|
|
447 }
|
|
448 name = name1;
|
|
449 p->name = name;
|
|
450
|
|
451 p->command = Qnil;
|
|
452 p->filter = Qnil;
|
|
453 p->sentinel = Qnil;
|
|
454 p->buffer = Qnil;
|
|
455 p->mark = Fmake_marker ();
|
|
456 p->pid = Qnil;
|
|
457 p->status_symbol = Qrun;
|
|
458 p->exit_code = 0;
|
|
459 p->core_dumped = 0;
|
|
460 p->filter_does_read = 0;
|
|
461 p->kill_without_query = 0;
|
|
462 p->selected = 0;
|
|
463 p->tick = 0;
|
|
464 p->update_tick = 0;
|
|
465 p->pipe_instream = Qnil;
|
|
466 p->pipe_outstream = Qnil;
|
|
467 #ifdef FILE_CODING
|
|
468 p->coding_instream = Qnil;
|
|
469 p->coding_outstream = Qnil;
|
|
470 #endif
|
|
471
|
|
472 p->process_data = 0;
|
|
473 MAYBE_PROCMETH (alloc_process_data, (p));
|
|
474
|
|
475 XSETPROCESS (val, p);
|
|
476
|
|
477 Vprocess_list = Fcons (val, Vprocess_list);
|
|
478 return val;
|
|
479 }
|
|
480
|
|
481 void
|
440
|
482 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags)
|
428
|
483 {
|
|
484 USID usid = event_stream_create_stream_pair (in, out,
|
563
|
485 &p->pipe_instream,
|
|
486 &p->pipe_outstream,
|
428
|
487 flags);
|
|
488
|
|
489 if (usid == USID_ERROR)
|
563
|
490 signal_error (Qprocess_error, "Setting up communication with subprocess",
|
|
491 Qunbound);
|
428
|
492
|
|
493 if (usid != USID_DONTHASH)
|
|
494 {
|
444
|
495 Lisp_Object process = Qnil;
|
|
496 XSETPROCESS (process, p);
|
|
497 puthash ((const void*)usid, LISP_TO_VOID (process), usid_to_process);
|
428
|
498 }
|
|
499
|
|
500 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags));
|
|
501
|
|
502 #ifdef FILE_CODING
|
|
503 p->coding_instream = make_decoding_input_stream
|
|
504 (XLSTREAM (p->pipe_instream),
|
|
505 Fget_coding_system (Vcoding_system_for_read));
|
|
506 Lstream_set_character_mode (XLSTREAM (p->coding_instream));
|
|
507 p->coding_outstream = make_encoding_output_stream
|
|
508 (XLSTREAM (p->pipe_outstream),
|
|
509 Fget_coding_system (Vcoding_system_for_write));
|
|
510 /* CODE_CNTL (&out_state[outchannel]) |= CC_END; !!####
|
|
511 What's going on here? */
|
|
512 #endif /* FILE_CODING */
|
|
513 }
|
|
514
|
|
515 static void
|
|
516 create_process (Lisp_Object process, Lisp_Object *argv, int nargv,
|
|
517 Lisp_Object program, Lisp_Object cur_dir)
|
|
518 {
|
440
|
519 Lisp_Process *p = XPROCESS (process);
|
428
|
520 int pid;
|
|
521
|
|
522 /* *_create_process may change status_symbol, if the process
|
|
523 is a kind of "fire-and-forget" (no I/O, unwaitable) */
|
|
524 p->status_symbol = Qrun;
|
|
525 p->exit_code = 0;
|
|
526
|
|
527 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir));
|
|
528
|
|
529 p->pid = make_int (pid);
|
440
|
530 if (PROCESS_LIVE_P (p))
|
428
|
531 event_stream_select_process (p);
|
|
532 }
|
|
533
|
|
534 /* This function is the unwind_protect form for Fstart_process_internal. If
|
444
|
535 PROCESS doesn't have its pid set, then we know someone has signalled
|
428
|
536 an error and the process wasn't started successfully, so we should
|
|
537 remove it from the process list. */
|
444
|
538 static void remove_process (Lisp_Object process);
|
428
|
539 static Lisp_Object
|
444
|
540 start_process_unwind (Lisp_Object process)
|
428
|
541 {
|
444
|
542 /* Was PROCESS started successfully? */
|
|
543 if (EQ (XPROCESS (process)->pid, Qnil))
|
|
544 remove_process (process);
|
428
|
545 return Qnil;
|
|
546 }
|
|
547
|
|
548 DEFUN ("start-process-internal", Fstart_process_internal, 3, MANY, 0, /*
|
|
549 Start a program in a subprocess. Return the process object for it.
|
|
550 Args are NAME BUFFER PROGRAM &rest PROGRAM-ARGS
|
|
551 NAME is name for process. It is modified if necessary to make it unique.
|
|
552 BUFFER is the buffer or (buffer-name) to associate with the process.
|
|
553 Process output goes at end of that buffer, unless you specify
|
|
554 an output stream or filter function to handle the output.
|
|
555 BUFFER may be also nil, meaning that this process is not associated
|
|
556 with any buffer
|
|
557 Third arg is program file name. It is searched for as in the shell.
|
|
558 Remaining arguments are strings to give program as arguments.
|
|
559 INCODE and OUTCODE specify the coding-system objects used in input/output
|
|
560 from/to the process.
|
|
561 */
|
|
562 (int nargs, Lisp_Object *args))
|
|
563 {
|
|
564 /* This function can call lisp */
|
|
565 /* !!#### This function has not been Mule-ized */
|
444
|
566 Lisp_Object buffer, name, program, process, current_dir;
|
428
|
567 Lisp_Object tem;
|
|
568 int speccount = specpdl_depth ();
|
|
569 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
570
|
|
571 name = args[0];
|
|
572 buffer = args[1];
|
|
573 program = args[2];
|
|
574 current_dir = Qnil;
|
|
575
|
|
576 /* Protect against various file handlers doing GCs below. */
|
|
577 GCPRO3 (buffer, program, current_dir);
|
|
578
|
|
579 if (!NILP (buffer))
|
|
580 buffer = Fget_buffer_create (buffer);
|
|
581
|
|
582 CHECK_STRING (name);
|
|
583 CHECK_STRING (program);
|
|
584
|
|
585 /* Make sure that the child will be able to chdir to the current
|
502
|
586 buffer's current directory, or its unhandled equivalent. [[ We
|
428
|
587 can't just have the child check for an error when it does the
|
502
|
588 chdir, since it's in a vfork. ]] -- not any more, we don't use
|
|
589 vfork. -ben
|
428
|
590
|
502
|
591 Note: These calls are spread out to insure that the return values
|
|
592 of the calls (which may be newly-created strings) are properly
|
|
593 GC-protected. */
|
428
|
594 current_dir = current_buffer->directory;
|
502
|
595 /* If the current dir has no terminating slash, we'll get undesirable
|
|
596 results, so put the slash back. */
|
|
597 current_dir = Ffile_name_as_directory (current_dir);
|
428
|
598 current_dir = Funhandled_file_name_directory (current_dir);
|
|
599 current_dir = expand_and_dir_to_file (current_dir, Qnil);
|
|
600
|
|
601 #if 0 /* This loser breaks ange-ftp */
|
|
602 /* dmoore - if you re-enable this code, you have to gcprotect
|
|
603 current_buffer through the above calls. */
|
|
604 if (NILP (Ffile_accessible_directory_p (current_dir)))
|
563
|
605 signal_error (Qprocess_error, "Setting current directory",
|
|
606 current_buffer->directory);
|
428
|
607 #endif /* 0 */
|
|
608
|
|
609 /* If program file name is not absolute, search our path for it */
|
|
610 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0))
|
|
611 && !(XSTRING_LENGTH (program) > 1
|
|
612 && IS_DEVICE_SEP (XSTRING_BYTE (program, 1))))
|
|
613 {
|
|
614 struct gcpro ngcpro1;
|
|
615
|
|
616 tem = Qnil;
|
|
617 NGCPRO1 (tem);
|
|
618 locate_file (Vexec_path, program, Vlisp_EXEC_SUFFIXES, &tem, X_OK);
|
|
619 if (NILP (tem))
|
563
|
620 signal_error (Qprocess_error, "Searching for program", program);
|
428
|
621 program = Fexpand_file_name (tem, Qnil);
|
|
622 NUNGCPRO;
|
|
623 }
|
|
624 else
|
|
625 {
|
442
|
626 /* we still need to canonicalize it and ensure it has the proper
|
|
627 ending, e.g. .exe */
|
|
628 struct gcpro ngcpro1;
|
|
629
|
|
630 tem = Qnil;
|
|
631 NGCPRO1 (tem);
|
|
632 locate_file (list1 (build_string ("")), program, Vlisp_EXEC_SUFFIXES,
|
|
633 &tem, X_OK);
|
|
634 if (NILP (tem))
|
563
|
635 signal_error (Qprocess_error, "Searching for program", program);
|
442
|
636 program = tem;
|
|
637 NUNGCPRO;
|
428
|
638 }
|
|
639
|
442
|
640 if (!NILP (Ffile_directory_p (program)))
|
|
641 invalid_operation ("Specified program for new process is a directory",
|
|
642 program);
|
|
643
|
444
|
644 process = make_process_internal (name);
|
428
|
645
|
444
|
646 XPROCESS (process)->buffer = buffer;
|
|
647 XPROCESS (process)->command = Flist (nargs - 2,
|
428
|
648 args + 2);
|
|
649
|
|
650 /* Make the process marker point into the process buffer (if any). */
|
|
651 if (!NILP (buffer))
|
444
|
652 Fset_marker (XPROCESS (process)->mark,
|
428
|
653 make_int (BUF_ZV (XBUFFER (buffer))), buffer);
|
|
654
|
|
655 /* If an error occurs and we can't start the process, we want to
|
|
656 remove it from the process list. This means that each error
|
|
657 check in create_process doesn't need to call remove_process
|
|
658 itself; it's all taken care of here. */
|
444
|
659 record_unwind_protect (start_process_unwind, process);
|
428
|
660
|
444
|
661 create_process (process, args + 3, nargs - 3, program, current_dir);
|
428
|
662
|
|
663 UNGCPRO;
|
444
|
664 return unbind_to (speccount, process);
|
428
|
665 }
|
|
666
|
|
667
|
|
668 #ifdef HAVE_SOCKETS
|
|
669
|
|
670
|
|
671 /* #### The network support is fairly synthetical. What we actually
|
|
672 need is a single function, which supports all datagram, stream and
|
|
673 packet stream connections, arbitrary protocol families should they
|
|
674 be supported by the target system, multicast groups, in both data
|
|
675 and control rooted/nonrooted flavors, service quality etc whatever
|
|
676 is supported by the underlying network.
|
|
677
|
|
678 It must accept a property list describing the connection. The current
|
|
679 functions must then go to lisp and provide a suitable list for the
|
|
680 generalized connection function.
|
|
681
|
|
682 Both UNIX and Win32 support BSD sockets, and there are many extensions
|
|
683 available (Sockets 2 spec).
|
|
684
|
|
685 A todo is define a consistent set of properties abstracting a
|
|
686 network connection. -kkm
|
|
687 */
|
|
688
|
|
689
|
|
690 /* open a TCP network connection to a given HOST/SERVICE. Treated
|
|
691 exactly like a normal process when reading and writing. Only
|
|
692 differences are in status display and process deletion. A network
|
|
693 connection has no PID; you cannot signal it. All you can do is
|
|
694 deactivate and close it via delete-process */
|
|
695
|
442
|
696 DEFUN ("open-network-stream-internal", Fopen_network_stream_internal, 4, 5,
|
|
697 0, /*
|
428
|
698 Open a TCP connection for a service to a host.
|
444
|
699 Return a process object to represent the connection.
|
428
|
700 Input and output work as for subprocesses; `delete-process' closes it.
|
|
701
|
|
702 NAME is name for process. It is modified if necessary to make it unique.
|
|
703 BUFFER is the buffer (or buffer-name) to associate with the process.
|
|
704 Process output goes at end of that buffer, unless you specify
|
|
705 an output stream or filter function to handle the output.
|
|
706 BUFFER may also be nil, meaning that this process is not associated
|
|
707 with any buffer.
|
444
|
708 Third arg HOST (a string) is the name of the host to connect to,
|
|
709 or its IP address.
|
|
710 Fourth arg SERVICE is the name of the service desired (a string),
|
|
711 or an integer specifying a port number to connect to.
|
|
712 Optional fifth arg PROTOCOL is a network protocol. Currently only 'tcp
|
428
|
713 (Transmission Control Protocol) and 'udp (User Datagram Protocol) are
|
|
714 supported. When omitted, 'tcp is assumed.
|
|
715
|
442
|
716 Output via `process-send-string' and input via buffer or filter (see
|
428
|
717 `set-process-filter') are stream-oriented. That means UDP datagrams are
|
|
718 not guaranteed to be sent and received in discrete packets. (But small
|
|
719 datagrams around 500 bytes that are not truncated by `process-send-string'
|
444
|
720 are usually fine.) Note further that the UDP protocol does not guard
|
|
721 against lost packets.
|
428
|
722 */
|
|
723 (name, buffer, host, service, protocol))
|
|
724 {
|
|
725 /* !!#### This function has not been Mule-ized */
|
|
726 /* This function can GC */
|
444
|
727 Lisp_Object process = Qnil;
|
428
|
728 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1;
|
|
729 void *inch, *outch;
|
|
730
|
|
731 GCPRO5 (name, buffer, host, service, protocol);
|
|
732 CHECK_STRING (name);
|
|
733
|
|
734 if (NILP(protocol))
|
|
735 protocol = Qtcp;
|
|
736 else
|
|
737 CHECK_SYMBOL (protocol);
|
|
738
|
|
739 /* Since this code is inside HAVE_SOCKETS, existence of
|
|
740 open_network_stream is mandatory */
|
|
741 PROCMETH (open_network_stream, (name, host, service, protocol,
|
|
742 &inch, &outch));
|
|
743
|
|
744 if (!NILP (buffer))
|
|
745 buffer = Fget_buffer_create (buffer);
|
444
|
746 process = make_process_internal (name);
|
|
747 NGCPRO1 (process);
|
428
|
748
|
444
|
749 XPROCESS (process)->pid = Fcons (service, host);
|
|
750 XPROCESS (process)->buffer = buffer;
|
|
751 init_process_io_handles (XPROCESS (process), (void*)inch, (void*)outch,
|
428
|
752 STREAM_NETWORK_CONNECTION);
|
|
753
|
444
|
754 event_stream_select_process (XPROCESS (process));
|
428
|
755
|
|
756 UNGCPRO;
|
|
757 NUNGCPRO;
|
444
|
758 return process;
|
428
|
759 }
|
|
760
|
|
761 #ifdef HAVE_MULTICAST
|
|
762
|
|
763 DEFUN ("open-multicast-group-internal", Fopen_multicast_group_internal, 5, 5, 0, /*
|
|
764 Open a multicast connection on the specified dest/port/ttl.
|
444
|
765 Return a process object to represent the connection.
|
428
|
766 Input and output work as for subprocesses; `delete-process' closes it.
|
|
767
|
|
768 NAME is name for process. It is modified if necessary to make it unique.
|
|
769 BUFFER is the buffer (or buffer-name) to associate with the process.
|
|
770 Process output goes at end of that buffer, unless you specify
|
|
771 an output stream or filter function to handle the output.
|
|
772 BUFFER may also be nil, meaning that this process is not associated
|
|
773 with any buffer.
|
|
774 Third, fourth and fifth args are the multicast destination group, port and ttl.
|
|
775 dest must be an internet address between 224.0.0.0 and 239.255.255.255
|
|
776 port is a communication port like in traditional unicast
|
|
777 ttl is the time-to-live (15 for site, 63 for region and 127 for world)
|
|
778 */
|
|
779 (name, buffer, dest, port, ttl))
|
|
780 {
|
|
781 /* !!#### This function has not been Mule-ized */
|
|
782 /* This function can GC */
|
444
|
783 Lisp_Object process = Qnil;
|
428
|
784 struct gcpro gcpro1;
|
|
785 void *inch, *outch;
|
|
786
|
|
787 CHECK_STRING (name);
|
|
788
|
|
789 /* Since this code is inside HAVE_MULTICAST, existence of
|
|
790 open_network_stream is mandatory */
|
|
791 PROCMETH (open_multicast_group, (name, dest, port, ttl,
|
|
792 &inch, &outch));
|
|
793
|
|
794 if (!NILP (buffer))
|
|
795 buffer = Fget_buffer_create (buffer);
|
|
796
|
444
|
797 process = make_process_internal (name);
|
|
798 GCPRO1 (process);
|
428
|
799
|
444
|
800 XPROCESS (process)->pid = Fcons (port, dest);
|
|
801 XPROCESS (process)->buffer = buffer;
|
|
802 init_process_io_handles (XPROCESS (process), (void*)inch, (void*)outch,
|
428
|
803 STREAM_NETWORK_CONNECTION);
|
|
804
|
444
|
805 event_stream_select_process (XPROCESS (process));
|
428
|
806
|
|
807 UNGCPRO;
|
444
|
808 return process;
|
428
|
809 }
|
|
810 #endif /* HAVE_MULTICAST */
|
|
811
|
|
812 #endif /* HAVE_SOCKETS */
|
|
813
|
|
814 Lisp_Object
|
|
815 canonicalize_host_name (Lisp_Object host)
|
|
816 {
|
|
817 return PROCMETH_OR_GIVEN (canonicalize_host_name, (host), host);
|
|
818 }
|
|
819
|
|
820
|
|
821 DEFUN ("set-process-window-size", Fset_process_window_size, 3, 3, 0, /*
|
|
822 Tell PROCESS that it has logical window size HEIGHT and WIDTH.
|
|
823 */
|
444
|
824 (process, height, width))
|
428
|
825 {
|
444
|
826 CHECK_PROCESS (process);
|
428
|
827 CHECK_NATNUM (height);
|
|
828 CHECK_NATNUM (width);
|
|
829 return
|
444
|
830 MAYBE_INT_PROCMETH (set_window_size,
|
|
831 (XPROCESS (process), XINT (height), XINT (width))) <= 0
|
428
|
832 ? Qnil : Qt;
|
|
833 }
|
|
834
|
|
835
|
|
836 /************************************************************************/
|
|
837 /* Process I/O */
|
|
838 /************************************************************************/
|
|
839
|
|
840 /* Read pending output from the process channel,
|
|
841 starting with our buffered-ahead character if we have one.
|
|
842 Yield number of characters read.
|
|
843
|
|
844 This function reads at most 1024 bytes.
|
|
845 If you want to read all available subprocess output,
|
|
846 you must call it repeatedly until it returns zero. */
|
|
847
|
|
848 Charcount
|
444
|
849 read_process_output (Lisp_Object process)
|
428
|
850 {
|
|
851 /* This function can GC */
|
|
852 Bytecount nbytes, nchars;
|
|
853 Bufbyte chars[1024];
|
|
854 Lisp_Object outstream;
|
444
|
855 Lisp_Process *p = XPROCESS (process);
|
428
|
856
|
|
857 /* If there is a lot of output from the subprocess, the loop in
|
|
858 execute_internal_event() might call read_process_output() more
|
|
859 than once. If the filter that was executed from one of these
|
|
860 calls set the filter to t, we have to stop now. Return -1 rather
|
|
861 than 0 so execute_internal_event() doesn't close the process.
|
|
862 Really, the loop in execute_internal_event() should check itself
|
|
863 for a process-filter change, like in status_notify(); but the
|
|
864 struct Lisp_Process is not exported outside of this file. */
|
440
|
865 if (!PROCESS_LIVE_P (p))
|
428
|
866 return -1; /* already closed */
|
|
867
|
|
868 if (!NILP (p->filter) && (p->filter_does_read))
|
|
869 {
|
|
870 Lisp_Object filter_result;
|
|
871
|
|
872 /* Some weird FSFmacs crap here with
|
|
873 Vdeactivate_mark and current_buffer->keymap */
|
|
874 running_asynch_code = 1;
|
|
875 filter_result = call2_trapping_errors ("Error in process filter",
|
444
|
876 p->filter, process, Qnil);
|
428
|
877 running_asynch_code = 0;
|
|
878 restore_match_data ();
|
|
879 CHECK_INT (filter_result);
|
|
880 return XINT (filter_result);
|
|
881 }
|
|
882
|
|
883 nbytes = Lstream_read (XLSTREAM (DATA_INSTREAM(p)), chars, sizeof (chars));
|
|
884 if (nbytes <= 0) return nbytes;
|
|
885
|
|
886 nchars = bytecount_to_charcount (chars, nbytes);
|
|
887 outstream = p->filter;
|
|
888 if (!NILP (outstream))
|
|
889 {
|
|
890 /* We used to bind inhibit-quit to t here, but
|
|
891 call2_trapping_errors() does that for us. */
|
|
892 running_asynch_code = 1;
|
|
893 call2_trapping_errors ("Error in process filter",
|
444
|
894 outstream, process, make_string (chars, nbytes));
|
428
|
895 running_asynch_code = 0;
|
|
896 restore_match_data ();
|
|
897 return nchars;
|
|
898 }
|
|
899
|
|
900 /* If no filter, write into buffer if it isn't dead. */
|
|
901 if (!NILP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
|
902 {
|
|
903 Lisp_Object old_read_only = Qnil;
|
|
904 Bufpos old_point;
|
|
905 Bufpos old_begv;
|
|
906 Bufpos old_zv;
|
|
907 struct gcpro gcpro1, gcpro2;
|
|
908 struct buffer *buf = XBUFFER (p->buffer);
|
|
909
|
444
|
910 GCPRO2 (process, old_read_only);
|
428
|
911
|
|
912 old_point = BUF_PT (buf);
|
|
913 old_begv = BUF_BEGV (buf);
|
|
914 old_zv = BUF_ZV (buf);
|
|
915 old_read_only = buf->read_only;
|
|
916 buf->read_only = Qnil;
|
|
917
|
|
918 /* Insert new output into buffer
|
|
919 at the current end-of-output marker,
|
|
920 thus preserving logical ordering of input and output. */
|
|
921 if (XMARKER (p->mark)->buffer)
|
|
922 BUF_SET_PT (buf,
|
|
923 bufpos_clip_to_bounds (old_begv, marker_position (p->mark),
|
|
924 old_zv));
|
|
925 else
|
|
926 BUF_SET_PT (buf, old_zv);
|
|
927
|
|
928 /* If the output marker is outside of the visible region, save
|
|
929 the restriction and widen. */
|
|
930 if (! (BUF_BEGV (buf) <= BUF_PT (buf) &&
|
|
931 BUF_PT (buf) <= BUF_ZV (buf)))
|
|
932 Fwiden (p->buffer);
|
|
933
|
|
934 /* Make sure opoint floats ahead of any new text, just as point
|
|
935 would. */
|
|
936 if (BUF_PT (buf) <= old_point)
|
|
937 old_point += nchars;
|
|
938
|
|
939 /* Insert after old_begv, but before old_zv. */
|
|
940 if (BUF_PT (buf) < old_begv)
|
|
941 old_begv += nchars;
|
|
942 if (BUF_PT (buf) <= old_zv)
|
|
943 old_zv += nchars;
|
|
944
|
|
945 #if 0
|
|
946 /* This screws up initial display of the window. jla */
|
|
947
|
|
948 /* Insert before markers in case we are inserting where
|
|
949 the buffer's mark is, and the user's next command is Meta-y. */
|
|
950 buffer_insert_raw_string_1 (buf, -1, chars,
|
|
951 nbytes, INSDEL_BEFORE_MARKERS);
|
|
952 #else
|
|
953 buffer_insert_raw_string (buf, chars, nbytes);
|
|
954 #endif
|
|
955
|
|
956 Fset_marker (p->mark, make_int (BUF_PT (buf)), p->buffer);
|
|
957
|
|
958 MARK_MODELINE_CHANGED;
|
|
959
|
|
960 /* If the restriction isn't what it should be, set it. */
|
|
961 if (old_begv != BUF_BEGV (buf) || old_zv != BUF_ZV (buf))
|
|
962 {
|
|
963 Fwiden(p->buffer);
|
|
964 old_begv = bufpos_clip_to_bounds (BUF_BEG (buf),
|
|
965 old_begv,
|
|
966 BUF_Z (buf));
|
|
967 old_zv = bufpos_clip_to_bounds (BUF_BEG (buf),
|
|
968 old_zv,
|
|
969 BUF_Z (buf));
|
|
970 Fnarrow_to_region (make_int (old_begv), make_int (old_zv),
|
|
971 p->buffer);
|
|
972 }
|
|
973
|
|
974 buf->read_only = old_read_only;
|
|
975 old_point = bufpos_clip_to_bounds (BUF_BEGV (buf),
|
|
976 old_point,
|
|
977 BUF_ZV (buf));
|
|
978 BUF_SET_PT (buf, old_point);
|
|
979
|
|
980 UNGCPRO;
|
|
981 }
|
|
982 return nchars;
|
|
983 }
|
|
984
|
|
985 /* Sending data to subprocess */
|
|
986
|
444
|
987 /* send some data to process PROCESS. If NONRELOCATABLE is non-NULL, it
|
428
|
988 specifies the address of the data. Otherwise, the data comes from the
|
|
989 object RELOCATABLE (either a string or a buffer). START and LEN
|
|
990 specify the offset and length of the data to send.
|
|
991
|
|
992 Note that START and LEN are in Bufpos's if RELOCATABLE is a buffer,
|
|
993 and in Bytecounts otherwise. */
|
|
994
|
|
995 void
|
444
|
996 send_process (Lisp_Object process,
|
442
|
997 Lisp_Object relocatable, const Bufbyte *nonrelocatable,
|
428
|
998 int start, int len)
|
|
999 {
|
|
1000 /* This function can GC */
|
|
1001 struct gcpro gcpro1, gcpro2;
|
|
1002 Lisp_Object lstream = Qnil;
|
|
1003
|
444
|
1004 GCPRO2 (process, lstream);
|
428
|
1005
|
444
|
1006 if (NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
563
|
1007 invalid_operation ("Process not open for writing", process);
|
428
|
1008
|
|
1009 if (nonrelocatable)
|
|
1010 lstream =
|
|
1011 make_fixed_buffer_input_stream (nonrelocatable + start, len);
|
|
1012 else if (BUFFERP (relocatable))
|
|
1013 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable),
|
|
1014 start, start + len, 0);
|
|
1015 else
|
|
1016 lstream = make_lisp_string_input_stream (relocatable, start, len);
|
|
1017
|
444
|
1018 PROCMETH (send_process, (process, XLSTREAM (lstream)));
|
428
|
1019
|
|
1020 UNGCPRO;
|
|
1021 Lstream_delete (XLSTREAM (lstream));
|
|
1022 }
|
|
1023
|
|
1024 DEFUN ("process-tty-name", Fprocess_tty_name, 1, 1, 0, /*
|
|
1025 Return the name of the terminal PROCESS uses, or nil if none.
|
|
1026 This is the terminal that the process itself reads and writes on,
|
|
1027 not the name of the pty that Emacs uses to talk with that terminal.
|
|
1028 */
|
444
|
1029 (process))
|
428
|
1030 {
|
444
|
1031 CHECK_PROCESS (process);
|
|
1032 return MAYBE_LISP_PROCMETH (get_tty_name, (XPROCESS (process)));
|
428
|
1033 }
|
|
1034
|
|
1035 DEFUN ("set-process-buffer", Fset_process_buffer, 2, 2, 0, /*
|
|
1036 Set buffer associated with PROCESS to BUFFER (a buffer, or nil).
|
|
1037 */
|
444
|
1038 (process, buffer))
|
428
|
1039 {
|
444
|
1040 CHECK_PROCESS (process);
|
428
|
1041 if (!NILP (buffer))
|
|
1042 CHECK_BUFFER (buffer);
|
444
|
1043 XPROCESS (process)->buffer = buffer;
|
428
|
1044 return buffer;
|
|
1045 }
|
|
1046
|
|
1047 DEFUN ("process-buffer", Fprocess_buffer, 1, 1, 0, /*
|
|
1048 Return the buffer PROCESS is associated with.
|
|
1049 Output from PROCESS is inserted in this buffer
|
|
1050 unless PROCESS has a filter.
|
|
1051 */
|
444
|
1052 (process))
|
428
|
1053 {
|
444
|
1054 CHECK_PROCESS (process);
|
|
1055 return XPROCESS (process)->buffer;
|
428
|
1056 }
|
|
1057
|
|
1058 DEFUN ("process-mark", Fprocess_mark, 1, 1, 0, /*
|
|
1059 Return the marker for the end of the last output from PROCESS.
|
|
1060 */
|
444
|
1061 (process))
|
428
|
1062 {
|
444
|
1063 CHECK_PROCESS (process);
|
|
1064 return XPROCESS (process)->mark;
|
428
|
1065 }
|
|
1066
|
|
1067 void
|
444
|
1068 set_process_filter (Lisp_Object process, Lisp_Object filter, int filter_does_read)
|
428
|
1069 {
|
444
|
1070 CHECK_PROCESS (process);
|
|
1071 if (PROCESS_LIVE_P (XPROCESS (process))) {
|
428
|
1072 if (EQ (filter, Qt))
|
444
|
1073 event_stream_unselect_process (XPROCESS (process));
|
428
|
1074 else
|
444
|
1075 event_stream_select_process (XPROCESS (process));
|
428
|
1076 }
|
|
1077
|
444
|
1078 XPROCESS (process)->filter = filter;
|
|
1079 XPROCESS (process)->filter_does_read = filter_does_read;
|
428
|
1080 }
|
|
1081
|
|
1082 DEFUN ("set-process-filter", Fset_process_filter, 2, 2, 0, /*
|
|
1083 Give PROCESS the filter function FILTER; nil means no filter.
|
|
1084 t means stop accepting output from the process.
|
|
1085 When a process has a filter, each time it does output
|
|
1086 the entire string of output is passed to the filter.
|
|
1087 The filter gets two arguments: the process and the string of output.
|
|
1088 If the process has a filter, its buffer is not used for output.
|
|
1089 */
|
444
|
1090 (process, filter))
|
428
|
1091 {
|
444
|
1092 set_process_filter (process, filter, 0);
|
428
|
1093 return filter;
|
|
1094 }
|
|
1095
|
|
1096 DEFUN ("process-filter", Fprocess_filter, 1, 1, 0, /*
|
|
1097 Return the filter function of PROCESS; nil if none.
|
|
1098 See `set-process-filter' for more info on filter functions.
|
|
1099 */
|
444
|
1100 (process))
|
428
|
1101 {
|
444
|
1102 CHECK_PROCESS (process);
|
|
1103 return XPROCESS (process)->filter;
|
428
|
1104 }
|
|
1105
|
442
|
1106 DEFUN ("process-send-region", Fprocess_send_region, 3, 4, 0, /*
|
|
1107 Send current contents of the region between START and END as input to PROCESS.
|
444
|
1108 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1109 name of a buffer, in which case the buffer's process is used. If it
|
|
1110 is nil, the current buffer's process is used.
|
442
|
1111 BUFFER specifies the buffer to look in; if nil, the current buffer is used.
|
444
|
1112 If STRING is more than 100 or so characters long, it may be sent in
|
|
1113 several chunks. This may happen even for shorter strings. Output
|
|
1114 from processes can arrive in between chunks.
|
428
|
1115 */
|
442
|
1116 (process, start, end, buffer))
|
428
|
1117 {
|
|
1118 /* This function can GC */
|
444
|
1119 Bufpos bstart, bend;
|
442
|
1120 struct buffer *buf = decode_buffer (buffer, 0);
|
428
|
1121
|
442
|
1122 XSETBUFFER (buffer, buf);
|
444
|
1123 process = get_process (process);
|
|
1124 get_buffer_range_char (buf, start, end, &bstart, &bend, 0);
|
442
|
1125
|
444
|
1126 send_process (process, buffer, 0, bstart, bend - bstart);
|
428
|
1127 return Qnil;
|
|
1128 }
|
|
1129
|
|
1130 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /*
|
|
1131 Send PROCESS the contents of STRING as input.
|
444
|
1132 PROCESS may be a process or the name of a process, or a buffer or the
|
|
1133 name of a buffer, in which case the buffer's process is used. If it
|
|
1134 is nil, the current buffer's process is used.
|
|
1135 Optional arguments START and END specify part of STRING; see `substring'.
|
|
1136 If STRING is more than 100 or so characters long, it may be sent in
|
|
1137 several chunks. This may happen even for shorter strings. Output
|
|
1138 from processes can arrive in between chunks.
|
428
|
1139 */
|
444
|
1140 (process, string, start, end))
|
428
|
1141 {
|
|
1142 /* This function can GC */
|
444
|
1143 Bytecount bstart, bend;
|
428
|
1144
|
444
|
1145 process = get_process (process);
|
428
|
1146 CHECK_STRING (string);
|
444
|
1147 get_string_range_byte (string, start, end, &bstart, &bend,
|
428
|
1148 GB_HISTORICAL_STRING_BEHAVIOR);
|
|
1149
|
444
|
1150 send_process (process, string, 0, bstart, bend - bstart);
|
428
|
1151 return Qnil;
|
|
1152 }
|
|
1153
|
|
1154 #ifdef FILE_CODING
|
|
1155
|
|
1156 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /*
|
|
1157 Return PROCESS's input coding system.
|
|
1158 */
|
|
1159 (process))
|
|
1160 {
|
|
1161 process = get_process (process);
|
440
|
1162 CHECK_LIVE_PROCESS (process);
|
428
|
1163 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) );
|
|
1164 }
|
|
1165
|
|
1166 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /*
|
|
1167 Return PROCESS's output coding system.
|
|
1168 */
|
|
1169 (process))
|
|
1170 {
|
|
1171 process = get_process (process);
|
440
|
1172 CHECK_LIVE_PROCESS (process);
|
428
|
1173 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream));
|
|
1174 }
|
|
1175
|
|
1176 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /*
|
|
1177 Return a pair of coding-system for decoding and encoding of PROCESS.
|
|
1178 */
|
|
1179 (process))
|
|
1180 {
|
|
1181 process = get_process (process);
|
440
|
1182 CHECK_LIVE_PROCESS (process);
|
428
|
1183 return Fcons (decoding_stream_coding_system
|
|
1184 (XLSTREAM (XPROCESS (process)->coding_instream)),
|
|
1185 encoding_stream_coding_system
|
|
1186 (XLSTREAM (XPROCESS (process)->coding_outstream)));
|
|
1187 }
|
|
1188
|
|
1189 DEFUN ("set-process-input-coding-system", Fset_process_input_coding_system,
|
|
1190 2, 2, 0, /*
|
|
1191 Set PROCESS's input coding system to CODESYS.
|
|
1192 */
|
|
1193 (process, codesys))
|
|
1194 {
|
|
1195 codesys = Fget_coding_system (codesys);
|
|
1196 process = get_process (process);
|
440
|
1197 CHECK_LIVE_PROCESS (process);
|
|
1198
|
428
|
1199 set_decoding_stream_coding_system
|
|
1200 (XLSTREAM (XPROCESS (process)->coding_instream), codesys);
|
|
1201 return Qnil;
|
|
1202 }
|
|
1203
|
|
1204 DEFUN ("set-process-output-coding-system", Fset_process_output_coding_system,
|
|
1205 2, 2, 0, /*
|
|
1206 Set PROCESS's output coding system to CODESYS.
|
|
1207 */
|
|
1208 (process, codesys))
|
|
1209 {
|
|
1210 codesys = Fget_coding_system (codesys);
|
|
1211 process = get_process (process);
|
440
|
1212 CHECK_LIVE_PROCESS (process);
|
|
1213
|
428
|
1214 set_encoding_stream_coding_system
|
|
1215 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys);
|
|
1216 return Qnil;
|
|
1217 }
|
|
1218
|
|
1219 DEFUN ("set-process-coding-system", Fset_process_coding_system,
|
|
1220 1, 3, 0, /*
|
|
1221 Set coding-systems of PROCESS to DECODING and ENCODING.
|
440
|
1222 DECODING will be used to decode subprocess output and ENCODING to
|
|
1223 encode subprocess input.
|
428
|
1224 */
|
|
1225 (process, decoding, encoding))
|
|
1226 {
|
|
1227 if (!NILP (decoding))
|
|
1228 Fset_process_input_coding_system (process, decoding);
|
|
1229
|
|
1230 if (!NILP (encoding))
|
|
1231 Fset_process_output_coding_system (process, encoding);
|
|
1232
|
|
1233 return Qnil;
|
|
1234 }
|
|
1235
|
|
1236 #endif /* FILE_CODING */
|
|
1237
|
|
1238 /************************************************************************/
|
|
1239 /* process status */
|
|
1240 /************************************************************************/
|
|
1241
|
|
1242 static Lisp_Object
|
|
1243 exec_sentinel_unwind (Lisp_Object datum)
|
|
1244 {
|
440
|
1245 Lisp_Cons *d = XCONS (datum);
|
428
|
1246 XPROCESS (d->car)->sentinel = d->cdr;
|
|
1247 free_cons (d);
|
|
1248 return Qnil;
|
|
1249 }
|
|
1250
|
|
1251 static void
|
444
|
1252 exec_sentinel (Lisp_Object process, Lisp_Object reason)
|
428
|
1253 {
|
|
1254 /* This function can GC */
|
|
1255 int speccount = specpdl_depth ();
|
444
|
1256 Lisp_Process *p = XPROCESS (process);
|
428
|
1257 Lisp_Object sentinel = p->sentinel;
|
|
1258
|
|
1259 if (NILP (sentinel))
|
|
1260 return;
|
|
1261
|
|
1262 /* Some weird FSFmacs crap here with
|
|
1263 Vdeactivate_mark and current_buffer->keymap */
|
|
1264
|
|
1265 /* Zilch the sentinel while it's running, to avoid recursive invocations;
|
|
1266 assure that it gets restored no matter how the sentinel exits. */
|
|
1267 p->sentinel = Qnil;
|
444
|
1268 record_unwind_protect (exec_sentinel_unwind, noseeum_cons (process, sentinel));
|
428
|
1269 /* We used to bind inhibit-quit to t here, but call2_trapping_errors()
|
|
1270 does that for us. */
|
|
1271 running_asynch_code = 1;
|
444
|
1272 call2_trapping_errors ("Error in process sentinel", sentinel, process, reason);
|
428
|
1273 running_asynch_code = 0;
|
|
1274 restore_match_data ();
|
|
1275 unbind_to (speccount, Qnil);
|
|
1276 }
|
|
1277
|
|
1278 DEFUN ("set-process-sentinel", Fset_process_sentinel, 2, 2, 0, /*
|
|
1279 Give PROCESS the sentinel SENTINEL; nil for none.
|
|
1280 The sentinel is called as a function when the process changes state.
|
|
1281 It gets two arguments: the process, and a string describing the change.
|
|
1282 */
|
444
|
1283 (process, sentinel))
|
428
|
1284 {
|
444
|
1285 CHECK_PROCESS (process);
|
|
1286 XPROCESS (process)->sentinel = sentinel;
|
428
|
1287 return sentinel;
|
|
1288 }
|
|
1289
|
|
1290 DEFUN ("process-sentinel", Fprocess_sentinel, 1, 1, 0, /*
|
|
1291 Return the sentinel of PROCESS; nil if none.
|
|
1292 See `set-process-sentinel' for more info on sentinels.
|
|
1293 */
|
444
|
1294 (process))
|
428
|
1295 {
|
444
|
1296 CHECK_PROCESS (process);
|
|
1297 return XPROCESS (process)->sentinel;
|
428
|
1298 }
|
|
1299
|
|
1300
|
442
|
1301 const char *
|
428
|
1302 signal_name (int signum)
|
|
1303 {
|
|
1304 if (signum >= 0 && signum < NSIG)
|
442
|
1305 return (const char *) sys_siglist[signum];
|
428
|
1306
|
442
|
1307 return (const char *) GETTEXT ("unknown signal");
|
428
|
1308 }
|
|
1309
|
|
1310 void
|
|
1311 update_process_status (Lisp_Object p,
|
|
1312 Lisp_Object status_symbol,
|
|
1313 int exit_code,
|
|
1314 int core_dumped)
|
|
1315 {
|
|
1316 XPROCESS (p)->tick++;
|
|
1317 process_tick++;
|
|
1318 XPROCESS (p)->status_symbol = status_symbol;
|
|
1319 XPROCESS (p)->exit_code = exit_code;
|
|
1320 XPROCESS (p)->core_dumped = core_dumped;
|
|
1321 }
|
|
1322
|
|
1323 /* Return a string describing a process status list. */
|
|
1324
|
|
1325 static Lisp_Object
|
440
|
1326 status_message (Lisp_Process *p)
|
428
|
1327 {
|
|
1328 Lisp_Object symbol = p->status_symbol;
|
|
1329 int code = p->exit_code;
|
|
1330 int coredump = p->core_dumped;
|
|
1331 Lisp_Object string, string2;
|
|
1332
|
|
1333 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop))
|
|
1334 {
|
|
1335 string = build_string (signal_name (code));
|
|
1336 if (coredump)
|
|
1337 string2 = build_translated_string (" (core dumped)\n");
|
|
1338 else
|
|
1339 string2 = build_string ("\n");
|
|
1340 set_string_char (XSTRING (string), 0,
|
|
1341 DOWNCASE (current_buffer,
|
|
1342 string_char (XSTRING (string), 0)));
|
|
1343 return concat2 (string, string2);
|
|
1344 }
|
|
1345 else if (EQ (symbol, Qexit))
|
|
1346 {
|
|
1347 if (code == 0)
|
|
1348 return build_translated_string ("finished\n");
|
|
1349 string = Fnumber_to_string (make_int (code));
|
|
1350 if (coredump)
|
|
1351 string2 = build_translated_string (" (core dumped)\n");
|
|
1352 else
|
|
1353 string2 = build_string ("\n");
|
|
1354 return concat2 (build_translated_string ("exited abnormally with code "),
|
|
1355 concat2 (string, string2));
|
|
1356 }
|
|
1357 else
|
|
1358 return Fcopy_sequence (Fsymbol_name (symbol));
|
|
1359 }
|
|
1360
|
|
1361 /* Tell status_notify() to check for terminated processes. We do this
|
|
1362 because on some systems we sometimes miss SIGCHLD calls. (Not sure
|
|
1363 why.) */
|
|
1364
|
|
1365 void
|
|
1366 kick_status_notify (void)
|
|
1367 {
|
|
1368 process_tick++;
|
|
1369 }
|
|
1370
|
|
1371
|
|
1372 /* Report all recent events of a change in process status
|
|
1373 (either run the sentinel or output a message).
|
|
1374 This is done while Emacs is waiting for keyboard input. */
|
|
1375
|
|
1376 void
|
|
1377 status_notify (void)
|
|
1378 {
|
|
1379 /* This function can GC */
|
|
1380 Lisp_Object tail = Qnil;
|
|
1381 Lisp_Object symbol = Qnil;
|
|
1382 Lisp_Object msg = Qnil;
|
|
1383 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1384 /* process_tick is volatile, so we have to remember it now.
|
444
|
1385 Otherwise, we get a race condition if SIGCHLD happens during
|
428
|
1386 this function.
|
|
1387
|
|
1388 (Actually, this is not the case anymore. The code to
|
|
1389 update the process structures has been moved out of the
|
|
1390 SIGCHLD handler. But for the moment I'm leaving this
|
|
1391 stuff in -- it can't hurt.) */
|
|
1392 int temp_process_tick;
|
|
1393
|
|
1394 MAYBE_PROCMETH (reap_exited_processes, ());
|
|
1395
|
|
1396 temp_process_tick = process_tick;
|
|
1397
|
|
1398 if (update_tick == temp_process_tick)
|
|
1399 return;
|
|
1400
|
|
1401 /* We need to gcpro tail; if read_process_output calls a filter
|
|
1402 which deletes a process and removes the cons to which tail points
|
|
1403 from Vprocess_alist, and then causes a GC, tail is an unprotected
|
|
1404 reference. */
|
|
1405 GCPRO3 (tail, symbol, msg);
|
|
1406
|
|
1407 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail))
|
|
1408 {
|
444
|
1409 Lisp_Object process = XCAR (tail);
|
|
1410 Lisp_Process *p = XPROCESS (process);
|
428
|
1411 /* p->tick is also volatile. Same thing as above applies. */
|
|
1412 int this_process_tick;
|
|
1413
|
|
1414 /* #### extra check for terminated processes, in case a SIGCHLD
|
|
1415 got missed (this seems to happen sometimes, I'm not sure why).
|
|
1416 */
|
|
1417 if (INTP (p->pid))
|
|
1418 MAYBE_PROCMETH (update_status_if_terminated, (p));
|
|
1419
|
|
1420 this_process_tick = p->tick;
|
|
1421 if (this_process_tick != p->update_tick)
|
|
1422 {
|
|
1423 p->update_tick = this_process_tick;
|
|
1424
|
|
1425 /* If process is still active, read any output that remains. */
|
|
1426 while (!EQ (p->filter, Qt)
|
444
|
1427 && read_process_output (process) > 0)
|
428
|
1428 ;
|
|
1429
|
|
1430 /* Get the text to use for the message. */
|
|
1431 msg = status_message (p);
|
|
1432
|
|
1433 /* If process is terminated, deactivate it or delete it. */
|
|
1434 symbol = p->status_symbol;
|
|
1435
|
|
1436 if (EQ (symbol, Qsignal)
|
|
1437 || EQ (symbol, Qexit))
|
|
1438 {
|
|
1439 if (delete_exited_processes)
|
444
|
1440 remove_process (process);
|
428
|
1441 else
|
444
|
1442 deactivate_process (process);
|
428
|
1443 }
|
|
1444
|
|
1445 /* Now output the message suitably. */
|
|
1446 if (!NILP (p->sentinel))
|
444
|
1447 exec_sentinel (process, msg);
|
428
|
1448 /* Don't bother with a message in the buffer
|
|
1449 when a process becomes runnable. */
|
|
1450 else if (!EQ (symbol, Qrun) && !NILP (p->buffer))
|
|
1451 {
|
|
1452 Lisp_Object old_read_only = Qnil;
|
|
1453 Lisp_Object old = Fcurrent_buffer ();
|
|
1454 Bufpos opoint;
|
|
1455 struct gcpro ngcpro1, ngcpro2;
|
|
1456
|
|
1457 /* Avoid error if buffer is deleted
|
|
1458 (probably that's why the process is dead, too) */
|
|
1459 if (!BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
|
1460 continue;
|
|
1461
|
|
1462 NGCPRO2 (old, old_read_only);
|
|
1463 Fset_buffer (p->buffer);
|
|
1464 opoint = BUF_PT (current_buffer);
|
|
1465 /* Insert new output into buffer
|
|
1466 at the current end-of-output marker,
|
|
1467 thus preserving logical ordering of input and output. */
|
|
1468 if (XMARKER (p->mark)->buffer)
|
|
1469 BUF_SET_PT (current_buffer, marker_position (p->mark));
|
|
1470 else
|
|
1471 BUF_SET_PT (current_buffer, BUF_ZV (current_buffer));
|
|
1472 if (BUF_PT (current_buffer) <= opoint)
|
|
1473 opoint += (string_char_length (XSTRING (msg))
|
|
1474 + string_char_length (XSTRING (p->name))
|
|
1475 + 10);
|
|
1476
|
|
1477 old_read_only = current_buffer->read_only;
|
|
1478 current_buffer->read_only = Qnil;
|
|
1479 buffer_insert_c_string (current_buffer, "\nProcess ");
|
|
1480 Finsert (1, &p->name);
|
|
1481 buffer_insert_c_string (current_buffer, " ");
|
|
1482 Finsert (1, &msg);
|
|
1483 current_buffer->read_only = old_read_only;
|
|
1484 Fset_marker (p->mark, make_int (BUF_PT (current_buffer)),
|
|
1485 p->buffer);
|
|
1486
|
|
1487 opoint = bufpos_clip_to_bounds(BUF_BEGV (XBUFFER (p->buffer)),
|
|
1488 opoint,
|
|
1489 BUF_ZV (XBUFFER (p->buffer)));
|
|
1490 BUF_SET_PT (current_buffer, opoint);
|
|
1491 Fset_buffer (old);
|
|
1492 NUNGCPRO;
|
|
1493 }
|
|
1494 }
|
|
1495 } /* end for */
|
|
1496
|
|
1497 /* in case buffers use %s in modeline-format */
|
|
1498 MARK_MODELINE_CHANGED;
|
|
1499 redisplay ();
|
|
1500
|
|
1501 update_tick = temp_process_tick;
|
|
1502
|
|
1503 UNGCPRO;
|
|
1504 }
|
|
1505
|
|
1506 DEFUN ("process-status", Fprocess_status, 1, 1, 0, /*
|
|
1507 Return the status of PROCESS.
|
|
1508 This is a symbol, one of these:
|
|
1509
|
|
1510 run -- for a process that is running.
|
|
1511 stop -- for a process stopped but continuable.
|
|
1512 exit -- for a process that has exited.
|
|
1513 signal -- for a process that has got a fatal signal.
|
|
1514 open -- for a network stream connection that is open.
|
|
1515 closed -- for a network stream connection that is closed.
|
|
1516 nil -- if arg is a process name and no such process exists.
|
|
1517
|
|
1518 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1519 nil, indicating the current buffer's process.
|
|
1520 */
|
444
|
1521 (process))
|
428
|
1522 {
|
|
1523 Lisp_Object status_symbol;
|
|
1524
|
444
|
1525 if (STRINGP (process))
|
|
1526 process = Fget_process (process);
|
428
|
1527 else
|
444
|
1528 process = get_process (process);
|
428
|
1529
|
444
|
1530 if (NILP (process))
|
428
|
1531 return Qnil;
|
|
1532
|
444
|
1533 status_symbol = XPROCESS (process)->status_symbol;
|
|
1534 if (network_connection_p (process))
|
428
|
1535 {
|
|
1536 if (EQ (status_symbol, Qrun))
|
|
1537 status_symbol = Qopen;
|
|
1538 else if (EQ (status_symbol, Qexit))
|
|
1539 status_symbol = Qclosed;
|
|
1540 }
|
|
1541 return status_symbol;
|
|
1542 }
|
|
1543
|
|
1544 DEFUN ("process-exit-status", Fprocess_exit_status, 1, 1, 0, /*
|
|
1545 Return the exit status of PROCESS or the signal number that killed it.
|
|
1546 If PROCESS has not yet exited or died, return 0.
|
|
1547 */
|
444
|
1548 (process))
|
428
|
1549 {
|
444
|
1550 CHECK_PROCESS (process);
|
|
1551 return make_int (XPROCESS (process)->exit_code);
|
428
|
1552 }
|
|
1553
|
|
1554
|
|
1555
|
442
|
1556 static int
|
|
1557 decode_signal (Lisp_Object signal_)
|
428
|
1558 {
|
442
|
1559 if (INTP (signal_))
|
|
1560 return XINT (signal_);
|
428
|
1561 else
|
|
1562 {
|
|
1563 Bufbyte *name;
|
|
1564
|
442
|
1565 CHECK_SYMBOL (signal_);
|
|
1566 name = string_data (XSYMBOL (signal_)->name);
|
428
|
1567
|
442
|
1568 #define handle_signal(sym) do { \
|
|
1569 if (!strcmp ((const char *) name, #sym)) \
|
|
1570 return sym; \
|
|
1571 } while (0)
|
428
|
1572
|
|
1573 handle_signal (SIGINT); /* ANSI */
|
|
1574 handle_signal (SIGILL); /* ANSI */
|
|
1575 handle_signal (SIGABRT); /* ANSI */
|
|
1576 handle_signal (SIGFPE); /* ANSI */
|
|
1577 handle_signal (SIGSEGV); /* ANSI */
|
|
1578 handle_signal (SIGTERM); /* ANSI */
|
|
1579
|
|
1580 #ifdef SIGHUP
|
|
1581 handle_signal (SIGHUP); /* POSIX */
|
|
1582 #endif
|
|
1583 #ifdef SIGQUIT
|
|
1584 handle_signal (SIGQUIT); /* POSIX */
|
|
1585 #endif
|
|
1586 #ifdef SIGTRAP
|
|
1587 handle_signal (SIGTRAP); /* POSIX */
|
|
1588 #endif
|
|
1589 #ifdef SIGKILL
|
|
1590 handle_signal (SIGKILL); /* POSIX */
|
|
1591 #endif
|
|
1592 #ifdef SIGUSR1
|
|
1593 handle_signal (SIGUSR1); /* POSIX */
|
|
1594 #endif
|
|
1595 #ifdef SIGUSR2
|
|
1596 handle_signal (SIGUSR2); /* POSIX */
|
|
1597 #endif
|
|
1598 #ifdef SIGPIPE
|
|
1599 handle_signal (SIGPIPE); /* POSIX */
|
|
1600 #endif
|
|
1601 #ifdef SIGALRM
|
|
1602 handle_signal (SIGALRM); /* POSIX */
|
|
1603 #endif
|
|
1604 #ifdef SIGCHLD
|
|
1605 handle_signal (SIGCHLD); /* POSIX */
|
|
1606 #endif
|
|
1607 #ifdef SIGCONT
|
|
1608 handle_signal (SIGCONT); /* POSIX */
|
|
1609 #endif
|
|
1610 #ifdef SIGSTOP
|
|
1611 handle_signal (SIGSTOP); /* POSIX */
|
|
1612 #endif
|
|
1613 #ifdef SIGTSTP
|
|
1614 handle_signal (SIGTSTP); /* POSIX */
|
|
1615 #endif
|
|
1616 #ifdef SIGTTIN
|
|
1617 handle_signal (SIGTTIN); /* POSIX */
|
|
1618 #endif
|
|
1619 #ifdef SIGTTOU
|
|
1620 handle_signal (SIGTTOU); /* POSIX */
|
|
1621 #endif
|
|
1622
|
|
1623 #ifdef SIGBUS
|
|
1624 handle_signal (SIGBUS); /* XPG5 */
|
|
1625 #endif
|
|
1626 #ifdef SIGPOLL
|
|
1627 handle_signal (SIGPOLL); /* XPG5 */
|
|
1628 #endif
|
|
1629 #ifdef SIGPROF
|
|
1630 handle_signal (SIGPROF); /* XPG5 */
|
|
1631 #endif
|
|
1632 #ifdef SIGSYS
|
|
1633 handle_signal (SIGSYS); /* XPG5 */
|
|
1634 #endif
|
|
1635 #ifdef SIGURG
|
|
1636 handle_signal (SIGURG); /* XPG5 */
|
|
1637 #endif
|
|
1638 #ifdef SIGXCPU
|
|
1639 handle_signal (SIGXCPU); /* XPG5 */
|
|
1640 #endif
|
|
1641 #ifdef SIGXFSZ
|
|
1642 handle_signal (SIGXFSZ); /* XPG5 */
|
|
1643 #endif
|
|
1644 #ifdef SIGVTALRM
|
|
1645 handle_signal (SIGVTALRM); /* XPG5 */
|
|
1646 #endif
|
|
1647
|
|
1648 #ifdef SIGIO
|
|
1649 handle_signal (SIGIO); /* BSD 4.2 */
|
|
1650 #endif
|
|
1651 #ifdef SIGWINCH
|
|
1652 handle_signal (SIGWINCH); /* BSD 4.3 */
|
|
1653 #endif
|
|
1654
|
|
1655 #ifdef SIGEMT
|
|
1656 handle_signal (SIGEMT);
|
|
1657 #endif
|
|
1658 #ifdef SIGINFO
|
|
1659 handle_signal (SIGINFO);
|
|
1660 #endif
|
|
1661 #ifdef SIGHWE
|
|
1662 handle_signal (SIGHWE);
|
|
1663 #endif
|
|
1664 #ifdef SIGPRE
|
|
1665 handle_signal (SIGPRE);
|
|
1666 #endif
|
|
1667 #ifdef SIGUME
|
|
1668 handle_signal (SIGUME);
|
|
1669 #endif
|
|
1670 #ifdef SIGDLK
|
|
1671 handle_signal (SIGDLK);
|
|
1672 #endif
|
|
1673 #ifdef SIGCPULIM
|
|
1674 handle_signal (SIGCPULIM);
|
|
1675 #endif
|
|
1676 #ifdef SIGIOT
|
|
1677 handle_signal (SIGIOT);
|
|
1678 #endif
|
|
1679 #ifdef SIGLOST
|
|
1680 handle_signal (SIGLOST);
|
|
1681 #endif
|
|
1682 #ifdef SIGSTKFLT
|
|
1683 handle_signal (SIGSTKFLT);
|
|
1684 #endif
|
|
1685 #ifdef SIGUNUSED
|
|
1686 handle_signal (SIGUNUSED);
|
|
1687 #endif
|
|
1688 #ifdef SIGDANGER
|
|
1689 handle_signal (SIGDANGER); /* AIX */
|
|
1690 #endif
|
|
1691 #ifdef SIGMSG
|
|
1692 handle_signal (SIGMSG);
|
|
1693 #endif
|
|
1694 #ifdef SIGSOUND
|
|
1695 handle_signal (SIGSOUND);
|
|
1696 #endif
|
|
1697 #ifdef SIGRETRACT
|
|
1698 handle_signal (SIGRETRACT);
|
|
1699 #endif
|
|
1700 #ifdef SIGGRANT
|
|
1701 handle_signal (SIGGRANT);
|
|
1702 #endif
|
|
1703 #ifdef SIGPWR
|
|
1704 handle_signal (SIGPWR);
|
|
1705 #endif
|
|
1706
|
|
1707 #undef handle_signal
|
|
1708
|
563
|
1709 invalid_constant ("Undefined signal name", signal_);
|
442
|
1710 return 0; /* Unreached */
|
|
1711 }
|
|
1712 }
|
|
1713
|
|
1714 /* Send signal number SIGNO to PROCESS.
|
|
1715 CURRENT-GROUP non-nil means send signal to the current
|
|
1716 foreground process group of the process's controlling terminal rather
|
|
1717 than to the process's own process group.
|
|
1718 This is used for various commands in shell mode.
|
|
1719 If NOMSG is zero, insert signal-announcements into process's buffers
|
|
1720 right away.
|
|
1721
|
|
1722 If we can, we try to signal PROCESS by sending control characters
|
|
1723 down the pty. This allows us to signal inferiors who have changed
|
|
1724 their uid, for which kill() would return an EPERM error, or to
|
|
1725 processes running on another computer through a remote login. */
|
|
1726
|
|
1727 static void
|
|
1728 process_send_signal (Lisp_Object process, int signo,
|
|
1729 int current_group, int nomsg)
|
|
1730 {
|
|
1731 /* This function can GC */
|
444
|
1732 process = get_process (process);
|
442
|
1733
|
444
|
1734 if (network_connection_p (process))
|
563
|
1735 invalid_operation ("Network connection is not a subprocess", process);
|
444
|
1736 CHECK_LIVE_PROCESS (process);
|
442
|
1737
|
444
|
1738 MAYBE_PROCMETH (kill_child_process, (process, signo, current_group, nomsg));
|
442
|
1739 }
|
|
1740
|
|
1741 DEFUN ("process-send-signal", Fprocess_send_signal, 1, 3, 0, /*
|
|
1742 Send signal SIGNAL to process PROCESS.
|
|
1743 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
1744 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1745 nil, indicating the current buffer's process.
|
|
1746 Third arg CURRENT-GROUP non-nil means send signal to the current
|
|
1747 foreground process group of the process's controlling terminal rather
|
|
1748 than to the process's own process group.
|
|
1749 If the process is a shell that supports job control, this means
|
|
1750 send the signal to the current subjob rather than the shell.
|
|
1751 */
|
|
1752 (signal_, process, current_group))
|
|
1753 {
|
|
1754 /* This function can GC */
|
|
1755 process_send_signal (process, decode_signal (signal_),
|
|
1756 !NILP (current_group), 0);
|
|
1757 return process;
|
|
1758 }
|
|
1759
|
|
1760 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /*
|
|
1761 Interrupt process PROCESS.
|
|
1762 See function `process-send-signal' for more details on usage.
|
|
1763 */
|
|
1764 (process, current_group))
|
|
1765 {
|
|
1766 /* This function can GC */
|
|
1767 process_send_signal (process, SIGINT, !NILP (current_group), 0);
|
|
1768 return process;
|
|
1769 }
|
|
1770
|
|
1771 DEFUN ("kill-process", Fkill_process, 0, 2, 0, /*
|
|
1772 Kill process PROCESS.
|
|
1773 See function `process-send-signal' for more details on usage.
|
|
1774 */
|
|
1775 (process, current_group))
|
|
1776 {
|
|
1777 /* This function can GC */
|
|
1778 #ifdef SIGKILL
|
|
1779 process_send_signal (process, SIGKILL, !NILP (current_group), 0);
|
|
1780 #else
|
563
|
1781 signal_error (Qunimplemented,
|
|
1782 "kill-process: Not supported on this system",
|
|
1783 Qunbound);
|
442
|
1784 #endif
|
|
1785 return process;
|
|
1786 }
|
|
1787
|
|
1788 DEFUN ("quit-process", Fquit_process, 0, 2, 0, /*
|
|
1789 Send QUIT signal to process PROCESS.
|
|
1790 See function `process-send-signal' for more details on usage.
|
|
1791 */
|
|
1792 (process, current_group))
|
|
1793 {
|
|
1794 /* This function can GC */
|
|
1795 #ifdef SIGQUIT
|
|
1796 process_send_signal (process, SIGQUIT, !NILP (current_group), 0);
|
|
1797 #else
|
563
|
1798 signal_error (Qunimplemented,
|
|
1799 "quit-process: Not supported on this system",
|
|
1800 Qunbound);
|
442
|
1801 #endif
|
|
1802 return process;
|
|
1803 }
|
|
1804
|
|
1805 DEFUN ("stop-process", Fstop_process, 0, 2, 0, /*
|
|
1806 Stop process PROCESS.
|
|
1807 See function `process-send-signal' for more details on usage.
|
|
1808 */
|
|
1809 (process, current_group))
|
|
1810 {
|
|
1811 /* This function can GC */
|
|
1812 #ifdef SIGTSTP
|
|
1813 process_send_signal (process, SIGTSTP, !NILP (current_group), 0);
|
|
1814 #else
|
563
|
1815 signal_error (Qunimplemented,
|
|
1816 "stop-process: Not supported on this system",
|
|
1817 Qunbound);
|
442
|
1818 #endif
|
|
1819 return process;
|
|
1820 }
|
|
1821
|
|
1822 DEFUN ("continue-process", Fcontinue_process, 0, 2, 0, /*
|
|
1823 Continue process PROCESS.
|
|
1824 See function `process-send-signal' for more details on usage.
|
|
1825 */
|
|
1826 (process, current_group))
|
|
1827 {
|
|
1828 /* This function can GC */
|
|
1829 #ifdef SIGCONT
|
|
1830 process_send_signal (process, SIGCONT, !NILP (current_group), 0);
|
|
1831 #else
|
563
|
1832 signal_error (Qunimplemented,
|
|
1833 "continue-process: Not supported on this system",
|
|
1834 Qunbound);
|
442
|
1835 #endif
|
|
1836 return process;
|
|
1837 }
|
|
1838
|
|
1839 DEFUN ("signal-process", Fsignal_process, 2, 2,
|
|
1840 "nProcess number: \nnSignal code: ", /*
|
|
1841 Send the process with process id PID the signal with code SIGNAL.
|
|
1842 PID must be an integer. The process need not be a child of this Emacs.
|
|
1843 SIGNAL may be an integer, or a symbol naming a signal, like `SIGSEGV'.
|
|
1844 */
|
|
1845 (pid, signal_))
|
|
1846 {
|
|
1847 CHECK_INT (pid);
|
|
1848
|
428
|
1849 return make_int (PROCMETH_OR_GIVEN (kill_process_by_pid,
|
442
|
1850 (XINT (pid), decode_signal (signal_)),
|
|
1851 -1));
|
428
|
1852 }
|
|
1853
|
|
1854 DEFUN ("process-send-eof", Fprocess_send_eof, 0, 1, 0, /*
|
|
1855 Make PROCESS see end-of-file in its input.
|
|
1856 PROCESS may be a process, a buffer, the name of a process or buffer, or
|
|
1857 nil, indicating the current buffer's process.
|
|
1858 If PROCESS is a network connection, or is a process communicating
|
|
1859 through a pipe (as opposed to a pty), then you cannot send any more
|
|
1860 text to PROCESS after you call this function.
|
|
1861 */
|
|
1862 (process))
|
|
1863 {
|
|
1864 /* This function can GC */
|
444
|
1865 process = get_process (process);
|
428
|
1866
|
|
1867 /* Make sure the process is really alive. */
|
444
|
1868 if (! EQ (XPROCESS (process)->status_symbol, Qrun))
|
563
|
1869 invalid_operation ("Process not running", process);
|
428
|
1870
|
444
|
1871 if (!MAYBE_INT_PROCMETH (process_send_eof, (process)))
|
428
|
1872 {
|
444
|
1873 if (!NILP (DATA_OUTSTREAM (XPROCESS (process))))
|
428
|
1874 {
|
444
|
1875 Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process))));
|
|
1876 event_stream_delete_stream_pair (Qnil, XPROCESS (process)->pipe_outstream);
|
|
1877 XPROCESS (process)->pipe_outstream = Qnil;
|
428
|
1878 #ifdef FILE_CODING
|
444
|
1879 XPROCESS (process)->coding_outstream = Qnil;
|
428
|
1880 #endif
|
|
1881 }
|
|
1882 }
|
|
1883
|
|
1884 return process;
|
|
1885 }
|
|
1886
|
|
1887
|
|
1888 /************************************************************************/
|
|
1889 /* deleting a process */
|
|
1890 /************************************************************************/
|
|
1891
|
|
1892 void
|
444
|
1893 deactivate_process (Lisp_Object process)
|
428
|
1894 {
|
444
|
1895 Lisp_Process *p = XPROCESS (process);
|
428
|
1896 USID usid;
|
|
1897
|
|
1898 /* It's possible that we got as far in the process-creation
|
|
1899 process as creating the descriptors but didn't get so
|
|
1900 far as selecting the process for input. In this
|
|
1901 case, p->pid is nil: p->pid is set at the same time that
|
|
1902 the process is selected for input. */
|
|
1903 /* #### The comment does not look correct. event_stream_unselect_process
|
|
1904 is guarded by process->selected, so this is not a problem. - kkm*/
|
|
1905 /* Must call this before setting the streams to nil */
|
|
1906 event_stream_unselect_process (p);
|
|
1907
|
|
1908 if (!NILP (DATA_OUTSTREAM (p)))
|
|
1909 Lstream_close (XLSTREAM (DATA_OUTSTREAM (p)));
|
|
1910 if (!NILP (DATA_INSTREAM (p)))
|
|
1911 Lstream_close (XLSTREAM (DATA_INSTREAM (p)));
|
|
1912
|
|
1913 /* Provide minimal implementation for deactivate_process
|
|
1914 if there's no process-specific one */
|
|
1915 if (HAS_PROCMETH_P (deactivate_process))
|
|
1916 usid = PROCMETH (deactivate_process, (p));
|
|
1917 else
|
|
1918 usid = event_stream_delete_stream_pair (p->pipe_instream,
|
|
1919 p->pipe_outstream);
|
|
1920
|
|
1921 if (usid != USID_DONTHASH)
|
442
|
1922 remhash ((const void*)usid, usid_to_process);
|
428
|
1923
|
|
1924 p->pipe_instream = Qnil;
|
|
1925 p->pipe_outstream = Qnil;
|
|
1926 #ifdef FILE_CODING
|
|
1927 p->coding_instream = Qnil;
|
|
1928 p->coding_outstream = Qnil;
|
|
1929 #endif
|
|
1930 }
|
|
1931
|
|
1932 static void
|
444
|
1933 remove_process (Lisp_Object process)
|
428
|
1934 {
|
444
|
1935 Vprocess_list = delq_no_quit (process, Vprocess_list);
|
|
1936 Fset_marker (XPROCESS (process)->mark, Qnil, Qnil);
|
428
|
1937
|
444
|
1938 deactivate_process (process);
|
428
|
1939 }
|
|
1940
|
|
1941 DEFUN ("delete-process", Fdelete_process, 1, 1, 0, /*
|
|
1942 Delete PROCESS: kill it and forget about it immediately.
|
|
1943 PROCESS may be a process or the name of one, or a buffer name.
|
|
1944 */
|
444
|
1945 (process))
|
428
|
1946 {
|
|
1947 /* This function can GC */
|
440
|
1948 Lisp_Process *p;
|
444
|
1949 process = get_process (process);
|
|
1950 p = XPROCESS (process);
|
|
1951 if (network_connection_p (process))
|
428
|
1952 {
|
|
1953 p->status_symbol = Qexit;
|
|
1954 p->exit_code = 0;
|
|
1955 p->core_dumped = 0;
|
|
1956 p->tick++;
|
|
1957 process_tick++;
|
|
1958 }
|
440
|
1959 else if (PROCESS_LIVE_P (p))
|
428
|
1960 {
|
444
|
1961 Fkill_process (process, Qnil);
|
428
|
1962 /* Do this now, since remove_process will make sigchld_handler do nothing. */
|
|
1963 p->status_symbol = Qsignal;
|
|
1964 p->exit_code = SIGKILL;
|
|
1965 p->core_dumped = 0;
|
|
1966 p->tick++;
|
|
1967 process_tick++;
|
|
1968 status_notify ();
|
|
1969 }
|
444
|
1970 remove_process (process);
|
428
|
1971 return Qnil;
|
|
1972 }
|
|
1973
|
|
1974 /* Kill all processes associated with `buffer'.
|
|
1975 If `buffer' is nil, kill all processes */
|
|
1976
|
|
1977 void
|
|
1978 kill_buffer_processes (Lisp_Object buffer)
|
|
1979 {
|
444
|
1980 LIST_LOOP_2 (process, Vprocess_list)
|
|
1981 if ((NILP (buffer) || EQ (XPROCESS (process)->buffer, buffer)))
|
|
1982 {
|
|
1983 if (network_connection_p (process))
|
|
1984 Fdelete_process (process);
|
|
1985 else if (PROCESS_LIVE_P (XPROCESS (process)))
|
|
1986 process_send_signal (process, SIGHUP, 0, 1);
|
|
1987 }
|
428
|
1988 }
|
|
1989
|
|
1990 DEFUN ("process-kill-without-query", Fprocess_kill_without_query, 1, 2, 0, /*
|
|
1991 Say no query needed if PROCESS is running when Emacs is exited.
|
|
1992 Optional second argument if non-nil says to require a query.
|
|
1993 Value is t if a query was formerly required.
|
|
1994 */
|
444
|
1995 (process, require_query_p))
|
428
|
1996 {
|
|
1997 int tem;
|
|
1998
|
444
|
1999 CHECK_PROCESS (process);
|
|
2000 tem = XPROCESS (process)->kill_without_query;
|
|
2001 XPROCESS (process)->kill_without_query = NILP (require_query_p);
|
428
|
2002
|
|
2003 return tem ? Qnil : Qt;
|
|
2004 }
|
|
2005
|
|
2006 DEFUN ("process-kill-without-query-p", Fprocess_kill_without_query_p, 1, 1, 0, /*
|
444
|
2007 Return t if PROCESS will be killed without query when emacs is exited.
|
428
|
2008 */
|
444
|
2009 (process))
|
428
|
2010 {
|
444
|
2011 CHECK_PROCESS (process);
|
|
2012 return XPROCESS (process)->kill_without_query ? Qt : Qnil;
|
428
|
2013 }
|
|
2014
|
|
2015
|
|
2016 /* This is not named init_process in order to avoid a conflict with NS 3.3 */
|
|
2017 void
|
|
2018 init_xemacs_process (void)
|
|
2019 {
|
|
2020 MAYBE_PROCMETH (init_process, ());
|
|
2021
|
|
2022 Vprocess_list = Qnil;
|
|
2023
|
|
2024 if (usid_to_process)
|
|
2025 clrhash (usid_to_process);
|
|
2026 else
|
|
2027 usid_to_process = make_hash_table (32);
|
|
2028 }
|
|
2029
|
|
2030 #if 0
|
|
2031
|
|
2032 xxDEFUN ("process-connection", Fprocess_connection, 0, 1, 0, /*
|
|
2033 Return the connection type of `PROCESS'. This can be nil (pipe),
|
|
2034 t or pty (pty) or stream (socket connection).
|
|
2035 */
|
|
2036 (process))
|
|
2037 {
|
|
2038 return XPROCESS (process)->type;
|
|
2039 }
|
|
2040
|
|
2041 #endif /* 0 */
|
|
2042
|
|
2043 void
|
|
2044 syms_of_process (void)
|
|
2045 {
|
442
|
2046 INIT_LRECORD_IMPLEMENTATION (process);
|
|
2047
|
563
|
2048 DEFSYMBOL (Qprocessp);
|
|
2049 DEFSYMBOL (Qprocess_live_p);
|
|
2050 DEFSYMBOL (Qrun);
|
|
2051 DEFSYMBOL (Qstop);
|
|
2052 DEFSYMBOL (Qopen);
|
|
2053 DEFSYMBOL (Qclosed);
|
428
|
2054
|
563
|
2055 DEFSYMBOL (Qtcp);
|
|
2056 DEFSYMBOL (Qudp);
|
428
|
2057
|
|
2058 #ifdef HAVE_MULTICAST
|
563
|
2059 DEFSYMBOL (Qmulticast); /* Used for occasional warnings */
|
428
|
2060 #endif
|
|
2061
|
563
|
2062 DEFERROR_STANDARD (Qprocess_error, Qio_error);
|
|
2063 DEFERROR_STANDARD (Qnetwork_error, Qio_error);
|
|
2064
|
428
|
2065 DEFSUBR (Fprocessp);
|
440
|
2066 DEFSUBR (Fprocess_live_p);
|
428
|
2067 DEFSUBR (Fget_process);
|
|
2068 DEFSUBR (Fget_buffer_process);
|
|
2069 DEFSUBR (Fdelete_process);
|
|
2070 DEFSUBR (Fprocess_status);
|
|
2071 DEFSUBR (Fprocess_exit_status);
|
|
2072 DEFSUBR (Fprocess_id);
|
|
2073 DEFSUBR (Fprocess_name);
|
|
2074 DEFSUBR (Fprocess_tty_name);
|
|
2075 DEFSUBR (Fprocess_command);
|
|
2076 DEFSUBR (Fset_process_buffer);
|
|
2077 DEFSUBR (Fprocess_buffer);
|
|
2078 DEFSUBR (Fprocess_mark);
|
|
2079 DEFSUBR (Fset_process_filter);
|
|
2080 DEFSUBR (Fprocess_filter);
|
|
2081 DEFSUBR (Fset_process_window_size);
|
|
2082 DEFSUBR (Fset_process_sentinel);
|
|
2083 DEFSUBR (Fprocess_sentinel);
|
|
2084 DEFSUBR (Fprocess_kill_without_query);
|
|
2085 DEFSUBR (Fprocess_kill_without_query_p);
|
|
2086 DEFSUBR (Fprocess_list);
|
|
2087 DEFSUBR (Fstart_process_internal);
|
|
2088 #ifdef HAVE_SOCKETS
|
|
2089 DEFSUBR (Fopen_network_stream_internal);
|
|
2090 #ifdef HAVE_MULTICAST
|
|
2091 DEFSUBR (Fopen_multicast_group_internal);
|
|
2092 #endif /* HAVE_MULTICAST */
|
|
2093 #endif /* HAVE_SOCKETS */
|
|
2094 DEFSUBR (Fprocess_send_region);
|
|
2095 DEFSUBR (Fprocess_send_string);
|
442
|
2096 DEFSUBR (Fprocess_send_signal);
|
428
|
2097 DEFSUBR (Finterrupt_process);
|
|
2098 DEFSUBR (Fkill_process);
|
|
2099 DEFSUBR (Fquit_process);
|
|
2100 DEFSUBR (Fstop_process);
|
|
2101 DEFSUBR (Fcontinue_process);
|
|
2102 DEFSUBR (Fprocess_send_eof);
|
|
2103 DEFSUBR (Fsignal_process);
|
|
2104 /* DEFSUBR (Fprocess_connection); */
|
|
2105 #ifdef FILE_CODING
|
|
2106 DEFSUBR (Fprocess_input_coding_system);
|
|
2107 DEFSUBR (Fprocess_output_coding_system);
|
|
2108 DEFSUBR (Fset_process_input_coding_system);
|
|
2109 DEFSUBR (Fset_process_output_coding_system);
|
|
2110 DEFSUBR (Fprocess_coding_system);
|
|
2111 DEFSUBR (Fset_process_coding_system);
|
|
2112 #endif /* FILE_CODING */
|
|
2113 }
|
|
2114
|
|
2115 void
|
|
2116 vars_of_process (void)
|
|
2117 {
|
|
2118 Fprovide (intern ("subprocesses"));
|
|
2119 #ifdef HAVE_SOCKETS
|
|
2120 Fprovide (intern ("network-streams"));
|
|
2121 #ifdef HAVE_MULTICAST
|
|
2122 Fprovide (intern ("multicast"));
|
|
2123 #endif /* HAVE_MULTICAST */
|
|
2124 #endif /* HAVE_SOCKETS */
|
|
2125 staticpro (&Vprocess_list);
|
|
2126
|
|
2127 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes /*
|
|
2128 *Non-nil means delete processes immediately when they exit.
|
|
2129 nil means don't delete them until `list-processes' is run.
|
|
2130 */ );
|
|
2131
|
|
2132 delete_exited_processes = 1;
|
|
2133
|
442
|
2134 DEFVAR_CONST_LISP ("null-device", &Vnull_device /*
|
|
2135 Name of the null device, which differs from system to system.
|
|
2136 The null device is a filename that acts as a sink for arbitrary amounts of
|
|
2137 data, which is discarded, or as a source for a zero-length file.
|
|
2138 It is available on all the systems that we currently support, but with
|
|
2139 different names (typically either `/dev/null' or `nul').
|
|
2140
|
|
2141 Note that there is also a /dev/zero on most modern Unix versions (including
|
|
2142 Cygwin), which acts like /dev/null when used as a sink, but as a source
|
|
2143 it sends a non-ending stream of zero bytes. It's used most often along
|
|
2144 with memory-mapping. We don't provide a Lisp variable for this because
|
|
2145 the operations needing this are lower level than what ELisp programs
|
|
2146 typically do, and in any case no equivalent exists under native MS Windows.
|
|
2147 */ );
|
|
2148 Vnull_device = build_string (NULL_DEVICE);
|
|
2149
|
428
|
2150 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /*
|
|
2151 Control type of device used to communicate with subprocesses.
|
|
2152 Values are nil to use a pipe, or t or `pty' to use a pty.
|
|
2153 The value has no effect if the system has no ptys or if all ptys are busy:
|
|
2154 then a pipe is used in any case.
|
|
2155 The value takes effect when `start-process' is called.
|
|
2156 */ );
|
|
2157 Vprocess_connection_type = Qt;
|
|
2158
|
|
2159 DEFVAR_BOOL ("windowed-process-io", &windowed_process_io /*
|
|
2160 Enables input/output on standard handles of a windowed process.
|
|
2161 When this variable is nil (the default), XEmacs does not attempt to read
|
|
2162 standard output handle of a windowed process. Instead, the process is
|
|
2163 immediately marked as exited immediately upon successful launching. This is
|
|
2164 done because normal windowed processes do not use standard I/O, as they are
|
|
2165 not connected to any console.
|
|
2166
|
|
2167 When launching a specially crafted windowed process, which expects to be
|
|
2168 launched by XEmacs, or by other program which pipes its standard input and
|
|
2169 output, this variable must be set to non-nil, in which case XEmacs will
|
|
2170 treat this process just like a console process.
|
|
2171
|
|
2172 NOTE: You should never set this variable, only bind it.
|
|
2173
|
|
2174 Only Windows processes can be "windowed" or "console". This variable has no
|
|
2175 effect on UNIX processes, because all UNIX processes are "console".
|
|
2176 */ );
|
|
2177 windowed_process_io = 0;
|
|
2178
|
|
2179 #ifdef PROCESS_IO_BLOCKING
|
|
2180 DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /*
|
|
2181 List of port numbers or port names to set a blocking I/O mode with connection.
|
|
2182 Nil value means to set a default(non-blocking) I/O mode.
|
|
2183 The value takes effect when `open-network-stream-internal' is called.
|
|
2184 */ );
|
|
2185 network_stream_blocking_port_list = Qnil;
|
|
2186 #endif /* PROCESS_IO_BLOCKING */
|
|
2187 }
|
|
2188
|
|
2189 #endif /* not NO_SUBPROCESSES */
|