annotate src/process.c @ 801:2b676dc88c66

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