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