annotate src/process.c @ 263:727739f917cb r20-5b30

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