comparison src/process.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children 41dbb7a9d5f2
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
56 #include "systime.h" 56 #include "systime.h"
57 #include "syssignal.h" /* Always include before systty.h */ 57 #include "syssignal.h" /* Always include before systty.h */
58 #include "systty.h" 58 #include "systty.h"
59 #include "syswait.h" 59 #include "syswait.h"
60 60
61 Lisp_Object Qprocessp, Qprocess_live_p; 61 Lisp_Object Qprocessp;
62 62
63 /* Process methods */ 63 /* Process methods */
64 struct process_methods the_process_methods; 64 struct process_methods the_process_methods;
65 65
66 /* a process object is a network connection when its pid field a cons 66 /* a process object is a network connection when its pid field a cons
69 /* Valid values of process->status_symbol */ 69 /* Valid values of process->status_symbol */
70 Lisp_Object Qrun, Qstop; 70 Lisp_Object Qrun, Qstop;
71 /* Qrun => Qopen, Qexit => Qclosed for "network connection" processes */ 71 /* Qrun => Qopen, Qexit => Qclosed for "network connection" processes */
72 Lisp_Object Qopen, Qclosed; 72 Lisp_Object Qopen, Qclosed;
73 /* Protocol families */ 73 /* Protocol families */
74 Lisp_Object Qtcp, Qudp; 74 Lisp_Object Qtcpip;
75 75
76 #ifdef HAVE_MULTICAST 76 #ifdef HAVE_MULTICAST
77 Lisp_Object Qmulticast; /* Will be used for occasional warnings */ 77 Lisp_Object Qmulticast; /* Will be used for occasional warnings */
78 #endif 78 #endif
79 79
105 105
106 /* List of process objects. */ 106 /* List of process objects. */
107 Lisp_Object Vprocess_list; 107 Lisp_Object Vprocess_list;
108 108
109 extern Lisp_Object Vlisp_EXEC_SUFFIXES; 109 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
110 Lisp_Object Vnull_device;
111 110
112 111
113 112
114 static Lisp_Object 113 static Lisp_Object
115 mark_process (Lisp_Object obj) 114 mark_process (Lisp_Object obj, void (*markobj) (Lisp_Object))
116 { 115 {
117 Lisp_Process *proc = XPROCESS (obj); 116 struct Lisp_Process *proc = XPROCESS (obj);
118 MAYBE_PROCMETH (mark_process_data, (proc)); 117 MAYBE_PROCMETH (mark_process_data, (proc, markobj));
119 mark_object (proc->name); 118 markobj (proc->name);
120 mark_object (proc->command); 119 markobj (proc->command);
121 mark_object (proc->filter); 120 markobj (proc->filter);
122 mark_object (proc->sentinel); 121 markobj (proc->sentinel);
123 mark_object (proc->buffer); 122 markobj (proc->buffer);
124 mark_object (proc->mark); 123 markobj (proc->mark);
125 mark_object (proc->pid); 124 markobj (proc->pid);
126 mark_object (proc->pipe_instream); 125 markobj (proc->pipe_instream);
127 mark_object (proc->pipe_outstream); 126 markobj (proc->pipe_outstream);
128 #ifdef FILE_CODING 127 #ifdef FILE_CODING
129 mark_object (proc->coding_instream); 128 markobj (proc->coding_instream);
130 mark_object (proc->coding_outstream); 129 markobj (proc->coding_outstream);
131 #endif 130 #endif
132 return proc->status_symbol; 131 return proc->status_symbol;
133 } 132 }
134 133
135 static void 134 static void
136 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 135 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
137 { 136 {
138 Lisp_Process *proc = XPROCESS (obj); 137 struct Lisp_Process *proc = XPROCESS (obj);
139 138
140 if (print_readably) 139 if (print_readably)
141 error ("printing unreadable object #<process %s>", 140 error ("printing unreadable object #<process %s>",
142 XSTRING_DATA (proc->name)); 141 XSTRING_DATA (proc->name));
143 142
146 print_internal (proc->name, printcharfun, 0); 145 print_internal (proc->name, printcharfun, 0);
147 } 146 }
148 else 147 else
149 { 148 {
150 int netp = network_connection_p (obj); 149 int netp = network_connection_p (obj);
151 write_c_string ((netp ? GETTEXT ("#<network connection ") : 150 write_c_string (((netp) ? GETTEXT ("#<network connection ") :
152 GETTEXT ("#<process ")), printcharfun); 151 GETTEXT ("#<process ")), printcharfun);
153 print_internal (proc->name, printcharfun, 1); 152 print_internal (proc->name, printcharfun, 1);
154 write_c_string ((netp ? " " : " pid "), printcharfun); 153 write_c_string (((netp) ? " " : " pid "), printcharfun);
155 print_internal (proc->pid, printcharfun, 1); 154 print_internal (proc->pid, printcharfun, 1);
156 write_c_string (" state:", printcharfun); 155 write_c_string (" state:", printcharfun);
157 print_internal (proc->status_symbol, printcharfun, 1); 156 print_internal (proc->status_symbol, printcharfun, 1);
158 MAYBE_PROCMETH (print_process_data, (proc, printcharfun)); 157 MAYBE_PROCMETH (print_process_data, (proc, printcharfun));
159 write_c_string (">", printcharfun); 158 write_c_string (">", printcharfun);
160 } 159 }
161 } 160 }
162 161
163 #ifdef HAVE_WINDOW_SYSTEM 162 #ifdef HAVE_WINDOW_SYSTEM
164 extern void debug_process_finalization (Lisp_Process *p); 163 extern void debug_process_finalization (struct Lisp_Process *p);
165 #endif /* HAVE_WINDOW_SYSTEM */ 164 #endif /* HAVE_WINDOW_SYSTEM */
166 165
167 static void 166 static void
168 finalize_process (void *header, int for_disksave) 167 finalize_process (void *header, int for_disksave)
169 { 168 {
170 /* #### this probably needs to be tied into the tty event loop */ 169 /* #### this probably needs to be tied into the tty event loop */
171 /* #### when there is one */ 170 /* #### when there is one */
172 Lisp_Process *p = (Lisp_Process *) header; 171 struct Lisp_Process *p = (struct Lisp_Process *) header;
173 #ifdef HAVE_WINDOW_SYSTEM 172 #ifdef HAVE_WINDOW_SYSTEM
174 if (!for_disksave) 173 if (!for_disksave)
175 { 174 {
176 debug_process_finalization (p); 175 debug_process_finalization (p);
177 } 176 }
185 } 184 }
186 } 185 }
187 186
188 DEFINE_LRECORD_IMPLEMENTATION ("process", process, 187 DEFINE_LRECORD_IMPLEMENTATION ("process", process,
189 mark_process, print_process, finalize_process, 188 mark_process, print_process, finalize_process,
190 0, 0, 0, Lisp_Process); 189 0, 0, struct Lisp_Process);
191 190
192 /************************************************************************/ 191 /************************************************************************/
193 /* basic process accessors */ 192 /* basic process accessors */
194 /************************************************************************/ 193 /************************************************************************/
195 194
196 /* Under FILE_CODING, this function returns low-level streams, connected 195 /* Under FILE_CODING, this function returns low-level streams, connected
197 directly to the child process, rather than en/decoding FILE_CODING 196 directly to the child process, rather than en/decoding FILE_CODING
198 streams */ 197 streams */
199 void 198 void
200 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr) 199 get_process_streams (struct Lisp_Process *p,
200 Lisp_Object *instr, Lisp_Object *outstr)
201 { 201 {
202 assert (p); 202 assert (p);
203 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream)); 203 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream));
204 assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream)); 204 assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream));
205 *instr = p->pipe_instream; 205 *instr = p->pipe_instream;
206 *outstr = p->pipe_outstream; 206 *outstr = p->pipe_outstream;
207 } 207 }
208 208
209 Lisp_Process * 209 struct Lisp_Process *
210 get_process_from_usid (USID usid) 210 get_process_from_usid (USID usid)
211 { 211 {
212 const void *vval; 212 CONST void *vval;
213 213
214 assert (usid != USID_ERROR && usid != USID_DONTHASH); 214 assert (usid != USID_ERROR && usid != USID_DONTHASH);
215 215
216 if (gethash ((const void*)usid, usid_to_process, &vval)) 216 if (gethash ((CONST void*)usid, usid_to_process, &vval))
217 { 217 {
218 Lisp_Object proc; 218 Lisp_Object proc;
219 CVOID_TO_LISP (proc, vval); 219 CVOID_TO_LISP (proc, vval);
220 return XPROCESS (proc); 220 return XPROCESS (proc);
221 } 221 }
222 else 222 else
223 return 0; 223 return 0;
224 } 224 }
225 225
226 int 226 int
227 get_process_selected_p (Lisp_Process *p) 227 get_process_selected_p (struct Lisp_Process *p)
228 { 228 {
229 return p->selected; 229 return p->selected;
230 } 230 }
231 231
232 void 232 void
233 set_process_selected_p (Lisp_Process *p, int selected_p) 233 set_process_selected_p (struct Lisp_Process *p, int selected_p)
234 { 234 {
235 p->selected = !!selected_p; 235 p->selected = !!selected_p;
236 } 236 }
237 237
238 int 238 int
239 connected_via_filedesc_p (Lisp_Process *p) 239 connected_via_filedesc_p (struct Lisp_Process *p)
240 { 240 {
241 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p)); 241 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p));
242 } 242 }
243 243
244 #ifdef HAVE_SOCKETS 244 #ifdef HAVE_SOCKETS
245 int 245 int
246 network_connection_p (Lisp_Object process) 246 network_connection_p (Lisp_Object process)
247 { 247 {
248 return CONSP (XPROCESS (process)->pid); 248 return GC_CONSP (XPROCESS (process)->pid);
249 } 249 }
250 #endif 250 #endif
251 251
252 DEFUN ("processp", Fprocessp, 1, 1, 0, /* 252 DEFUN ("processp", Fprocessp, 1, 1, 0, /*
253 Return t if OBJECT is a process. 253 Return t if OBJECT is a process.
255 (obj)) 255 (obj))
256 { 256 {
257 return PROCESSP (obj) ? Qt : Qnil; 257 return PROCESSP (obj) ? Qt : Qnil;
258 } 258 }
259 259
260 DEFUN ("process-live-p", Fprocess_live_p, 1, 1, 0, /*
261 Return t if OBJECT is a process that is alive.
262 */
263 (obj))
264 {
265 return PROCESSP (obj) && PROCESS_LIVE_P (XPROCESS (obj)) ? Qt : Qnil;
266 }
267
268 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* 260 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /*
269 Return a list of all processes. 261 Return a list of all processes.
270 */ 262 */
271 ()) 263 ())
272 { 264 {
278 */ 270 */
279 (name)) 271 (name))
280 { 272 {
281 Lisp_Object tail; 273 Lisp_Object tail;
282 274
283 if (PROCESSP (name)) 275 if (GC_PROCESSP (name))
284 return name; 276 return name;
285 277
286 if (!gc_in_progress) 278 if (!gc_in_progress)
287 /* this only gets called during GC when emacs is going away as a result 279 /* this only gets called during GC when emacs is going away as a result
288 of a signal or crash. */ 280 of a signal or crash. */
289 CHECK_STRING (name); 281 CHECK_STRING (name);
290 282
291 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail)) 283 for (tail = Vprocess_list; GC_CONSP (tail); tail = XCDR (tail))
292 { 284 {
293 Lisp_Object proc = XCAR (tail); 285 Lisp_Object proc = XCAR (tail);
294 QUIT; 286 QUIT;
295 if (internal_equal (name, XPROCESS (proc)->name, 0)) 287 if (internal_equal (name, XPROCESS (proc)->name, 0))
296 return XCAR (tail); 288 return XCAR (tail);
304 */ 296 */
305 (name)) 297 (name))
306 { 298 {
307 Lisp_Object buf, tail, proc; 299 Lisp_Object buf, tail, proc;
308 300
309 if (NILP (name)) return Qnil; 301 if (GC_NILP (name)) return Qnil;
310 buf = Fget_buffer (name); 302 buf = Fget_buffer (name);
311 if (NILP (buf)) return Qnil; 303 if (GC_NILP (buf)) return Qnil;
312 304
313 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail)) 305 for (tail = Vprocess_list; GC_CONSP (tail); tail = XCDR (tail))
314 { 306 {
315 /* jwz: do not quit here - it isn't necessary, as there is no way for 307 /* jwz: do not quit here - it isn't necessary, as there is no way for
316 Vprocess_list to get circular or overwhelmingly long, and this 308 Vprocess_list to get circular or overwhelmingly long, and this
317 function is called from layout_mode_element under redisplay. */ 309 function is called from layout_mode_element under redisplay. */
318 /* QUIT; */ 310 /* QUIT; */
319 proc = XCAR (tail); 311 proc = XCAR (tail);
320 if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf)) 312 if (GC_PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
321 return proc; 313 return proc;
322 } 314 }
323 return Qnil; 315 return Qnil;
324 } 316 }
325 317
337 /* #### Look more closely into translating process names. */ 329 /* #### Look more closely into translating process names. */
338 #endif 330 #endif
339 331
340 /* This may be called during a GC from process_send_signal() from 332 /* This may be called during a GC from process_send_signal() from
341 kill_buffer_processes() if emacs decides to abort(). */ 333 kill_buffer_processes() if emacs decides to abort(). */
342 if (PROCESSP (name)) 334 if (GC_PROCESSP (name))
343 return name; 335 return name;
344 336
345 if (STRINGP (name)) 337 if (GC_STRINGP (name))
346 { 338 {
347 obj = Fget_process (name); 339 obj = Fget_process (name);
348 if (NILP (obj)) 340 if (GC_NILP (obj))
349 obj = Fget_buffer (name); 341 obj = Fget_buffer (name);
350 if (NILP (obj)) 342 if (GC_NILP (obj))
351 error ("Process %s does not exist", XSTRING_DATA (name)); 343 error ("Process %s does not exist", XSTRING_DATA (name));
352 } 344 }
353 else if (NILP (name)) 345 else if (GC_NILP (name))
354 obj = Fcurrent_buffer (); 346 obj = Fcurrent_buffer ();
355 else 347 else
356 obj = name; 348 obj = name;
357 349
358 /* Now obj should be either a buffer object or a process object. 350 /* Now obj should be either a buffer object or a process object.
359 */ 351 */
360 if (BUFFERP (obj)) 352 if (GC_BUFFERP (obj))
361 { 353 {
362 proc = Fget_buffer_process (obj); 354 proc = Fget_buffer_process (obj);
363 if (NILP (proc)) 355 if (GC_NILP (proc))
364 error ("Buffer %s has no process", XSTRING_DATA (XBUFFER(obj)->name)); 356 error ("Buffer %s has no process", XSTRING_DATA (XBUFFER(obj)->name));
365 } 357 }
366 else 358 else
367 { 359 {
368 /* #### This was commented out. Although, simple 360 /* #### This was commented out. Although, simple
422 Lisp_Object 414 Lisp_Object
423 make_process_internal (Lisp_Object name) 415 make_process_internal (Lisp_Object name)
424 { 416 {
425 Lisp_Object val, name1; 417 Lisp_Object val, name1;
426 int i; 418 int i;
427 Lisp_Process *p = alloc_lcrecord_type (Lisp_Process, &lrecord_process); 419 struct Lisp_Process *p =
420 alloc_lcrecord_type (struct Lisp_Process, &lrecord_process);
428 421
429 /* If name is already in use, modify it until it is unused. */ 422 /* If name is already in use, modify it until it is unused. */
430 name1 = name; 423 name1 = name;
431 for (i = 1; ; i++) 424 for (i = 1; ; i++)
432 { 425 {
469 Vprocess_list = Fcons (val, Vprocess_list); 462 Vprocess_list = Fcons (val, Vprocess_list);
470 return val; 463 return val;
471 } 464 }
472 465
473 void 466 void
474 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags) 467 init_process_io_handles (struct Lisp_Process *p, void* in, void* out, int flags)
475 { 468 {
476 USID usid = event_stream_create_stream_pair (in, out, 469 USID usid = event_stream_create_stream_pair (in, out,
477 &p->pipe_instream, &p->pipe_outstream, 470 &p->pipe_instream, &p->pipe_outstream,
478 flags); 471 flags);
479 472
482 475
483 if (usid != USID_DONTHASH) 476 if (usid != USID_DONTHASH)
484 { 477 {
485 Lisp_Object proc = Qnil; 478 Lisp_Object proc = Qnil;
486 XSETPROCESS (proc, p); 479 XSETPROCESS (proc, p);
487 puthash ((const void*)usid, LISP_TO_VOID (proc), usid_to_process); 480 puthash ((CONST void*)usid, LISP_TO_VOID (proc), usid_to_process);
488 } 481 }
489 482
490 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags)); 483 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags));
491 484
492 #ifdef FILE_CODING 485 #ifdef FILE_CODING
504 497
505 static void 498 static void
506 create_process (Lisp_Object process, Lisp_Object *argv, int nargv, 499 create_process (Lisp_Object process, Lisp_Object *argv, int nargv,
507 Lisp_Object program, Lisp_Object cur_dir) 500 Lisp_Object program, Lisp_Object cur_dir)
508 { 501 {
509 Lisp_Process *p = XPROCESS (process); 502 struct Lisp_Process *p = XPROCESS (process);
510 int pid; 503 int pid;
511 504
512 /* *_create_process may change status_symbol, if the process 505 /* *_create_process may change status_symbol, if the process
513 is a kind of "fire-and-forget" (no I/O, unwaitable) */ 506 is a kind of "fire-and-forget" (no I/O, unwaitable) */
514 p->status_symbol = Qrun; 507 p->status_symbol = Qrun;
515 p->exit_code = 0; 508 p->exit_code = 0;
516 509
517 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir)); 510 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir));
518 511
519 p->pid = make_int (pid); 512 p->pid = make_int (pid);
520 if (PROCESS_LIVE_P (p)) 513 if (!NILP(p->pipe_instream))
521 event_stream_select_process (p); 514 event_stream_select_process (p);
522 } 515 }
523 516
524 /* This function is the unwind_protect form for Fstart_process_internal. If 517 /* This function is the unwind_protect form for Fstart_process_internal. If
525 PROC doesn't have its pid set, then we know someone has signalled 518 PROC doesn't have its pid set, then we know someone has signalled
664 connection has no PID; you cannot signal it. All you can do is 657 connection has no PID; you cannot signal it. All you can do is
665 deactivate and close it via delete-process */ 658 deactivate and close it via delete-process */
666 659
667 DEFUN ("open-network-stream-internal", Fopen_network_stream_internal, 4, 5, 0, /* 660 DEFUN ("open-network-stream-internal", Fopen_network_stream_internal, 4, 5, 0, /*
668 Open a TCP connection for a service to a host. 661 Open a TCP connection for a service to a host.
669 Return a subprocess-object to represent the connection. 662 Returns a subprocess-object to represent the connection.
670 Input and output work as for subprocesses; `delete-process' closes it. 663 Input and output work as for subprocesses; `delete-process' closes it.
671 664
672 NAME is name for process. It is modified if necessary to make it unique. 665 NAME is name for process. It is modified if necessary to make it unique.
673 BUFFER is the buffer (or buffer-name) to associate with the process. 666 BUFFER is the buffer (or buffer-name) to associate with the process.
674 Process output goes at end of that buffer, unless you specify 667 Process output goes at end of that buffer, unless you specify
676 BUFFER may also be nil, meaning that this process is not associated 669 BUFFER may also be nil, meaning that this process is not associated
677 with any buffer. 670 with any buffer.
678 Third arg is name of the host to connect to, or its IP address. 671 Third arg is name of the host to connect to, or its IP address.
679 Fourth arg SERVICE is name of the service desired, or an integer 672 Fourth arg SERVICE is name of the service desired, or an integer
680 specifying a port number to connect to. 673 specifying a port number to connect to.
681 Fifth argument PROTOCOL is a network protocol. Currently 'tcp 674 Fifth argument FAMILY is a protocol family. When omitted, 'tcp/ip
682 (Transmission Control Protocol) and 'udp (User Datagram Protocol) are 675 \(Internet protocol family TCP/IP) is assumed.
683 supported. When omitted, 'tcp is assumed. 676 */
684 677 (name, buffer, host, service, family))
685 Ouput via `process-send-string' and input via buffer or filter (see
686 `set-process-filter') are stream-oriented. That means UDP datagrams are
687 not guaranteed to be sent and received in discrete packets. (But small
688 datagrams around 500 bytes that are not truncated by `process-send-string'
689 are usually fine.) Note further that UDP protocol does not guard against
690 lost packets.
691 */
692 (name, buffer, host, service, protocol))
693 { 678 {
694 /* !!#### This function has not been Mule-ized */ 679 /* !!#### This function has not been Mule-ized */
695 /* This function can GC */ 680 /* This function can GC */
696 Lisp_Object proc = Qnil; 681 Lisp_Object proc = Qnil;
697 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1; 682 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1;
698 void *inch, *outch; 683 void *inch, *outch;
699 684
700 GCPRO5 (name, buffer, host, service, protocol); 685 GCPRO5 (name, buffer, host, service, family);
701 CHECK_STRING (name); 686 CHECK_STRING (name);
702 687
703 if (NILP(protocol)) 688 if (NILP(family))
704 protocol = Qtcp; 689 family = Qtcpip;
705 else 690 else
706 CHECK_SYMBOL (protocol); 691 CHECK_SYMBOL (family);
707 692
708 /* Since this code is inside HAVE_SOCKETS, existence of 693 /* Since this code is inside HAVE_SOCKETS, existence of
709 open_network_stream is mandatory */ 694 open_network_stream is mandatory */
710 PROCMETH (open_network_stream, (name, host, service, protocol, 695 PROCMETH (open_network_stream, (name, host, service, family,
711 &inch, &outch)); 696 &inch, &outch));
712 697
713 if (!NILP (buffer)) 698 if (!NILP (buffer))
714 buffer = Fget_buffer_create (buffer); 699 buffer = Fget_buffer_create (buffer);
715 proc = make_process_internal (name); 700 proc = make_process_internal (name);
729 714
730 #ifdef HAVE_MULTICAST 715 #ifdef HAVE_MULTICAST
731 716
732 DEFUN ("open-multicast-group-internal", Fopen_multicast_group_internal, 5, 5, 0, /* 717 DEFUN ("open-multicast-group-internal", Fopen_multicast_group_internal, 5, 5, 0, /*
733 Open a multicast connection on the specified dest/port/ttl. 718 Open a multicast connection on the specified dest/port/ttl.
734 Return a subprocess-object to represent the connection. 719 Returns a subprocess-object to represent the connection.
735 Input and output work as for subprocesses; `delete-process' closes it. 720 Input and output work as for subprocesses; `delete-process' closes it.
736 721
737 NAME is name for process. It is modified if necessary to make it unique. 722 NAME is name for process. It is modified if necessary to make it unique.
738 BUFFER is the buffer (or buffer-name) to associate with the process. 723 BUFFER is the buffer (or buffer-name) to associate with the process.
739 Process output goes at end of that buffer, unless you specify 724 Process output goes at end of that buffer, unless you specify
818 { 803 {
819 /* This function can GC */ 804 /* This function can GC */
820 Bytecount nbytes, nchars; 805 Bytecount nbytes, nchars;
821 Bufbyte chars[1024]; 806 Bufbyte chars[1024];
822 Lisp_Object outstream; 807 Lisp_Object outstream;
823 Lisp_Process *p = XPROCESS (proc); 808 struct Lisp_Process *p = XPROCESS (proc);
824 809
825 /* If there is a lot of output from the subprocess, the loop in 810 /* If there is a lot of output from the subprocess, the loop in
826 execute_internal_event() might call read_process_output() more 811 execute_internal_event() might call read_process_output() more
827 than once. If the filter that was executed from one of these 812 than once. If the filter that was executed from one of these
828 calls set the filter to t, we have to stop now. Return -1 rather 813 calls set the filter to t, we have to stop now. Return -1 rather
829 than 0 so execute_internal_event() doesn't close the process. 814 than 0 so execute_internal_event() doesn't close the process.
830 Really, the loop in execute_internal_event() should check itself 815 Really, the loop in execute_internal_event() should check itself
831 for a process-filter change, like in status_notify(); but the 816 for a process-filter change, like in status_notify(); but the
832 struct Lisp_Process is not exported outside of this file. */ 817 struct Lisp_Process is not exported outside of this file. */
833 if (!PROCESS_LIVE_P (p)) 818 if (NILP(p->pipe_instream))
834 return -1; /* already closed */ 819 return -1; /* already closed */
835 820
836 if (!NILP (p->filter) && (p->filter_does_read)) 821 if (!NILP (p->filter) && (p->filter_does_read))
837 { 822 {
838 Lisp_Object filter_result; 823 Lisp_Object filter_result;
963 Note that START and LEN are in Bufpos's if RELOCATABLE is a buffer, 948 Note that START and LEN are in Bufpos's if RELOCATABLE is a buffer,
964 and in Bytecounts otherwise. */ 949 and in Bytecounts otherwise. */
965 950
966 void 951 void
967 send_process (Lisp_Object proc, 952 send_process (Lisp_Object proc,
968 Lisp_Object relocatable, const Bufbyte *nonrelocatable, 953 Lisp_Object relocatable, CONST Bufbyte *nonrelocatable,
969 int start, int len) 954 int start, int len)
970 { 955 {
971 /* This function can GC */ 956 /* This function can GC */
972 struct gcpro gcpro1, gcpro2; 957 struct gcpro gcpro1, gcpro2;
973 Lisp_Object lstream = Qnil; 958 Lisp_Object lstream = Qnil;
978 signal_simple_error ("Process not open for writing", proc); 963 signal_simple_error ("Process not open for writing", proc);
979 964
980 if (nonrelocatable) 965 if (nonrelocatable)
981 lstream = 966 lstream =
982 make_fixed_buffer_input_stream (nonrelocatable + start, len); 967 make_fixed_buffer_input_stream (nonrelocatable + start, len);
983 else if (BUFFERP (relocatable)) 968 else if (GC_BUFFERP (relocatable))
984 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable), 969 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable),
985 start, start + len, 0); 970 start, start + len, 0);
986 else 971 else
987 lstream = make_lisp_string_input_stream (relocatable, start, len); 972 lstream = make_lisp_string_input_stream (relocatable, start, len);
988 973
1037 1022
1038 void 1023 void
1039 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read) 1024 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read)
1040 { 1025 {
1041 CHECK_PROCESS (proc); 1026 CHECK_PROCESS (proc);
1042 if (PROCESS_LIVE_P (XPROCESS (proc))) { 1027 if (PROCESS_LIVE_P (proc)) {
1043 if (EQ (filter, Qt)) 1028 if (EQ (filter, Qt))
1044 event_stream_unselect_process (XPROCESS (proc)); 1029 event_stream_unselect_process (XPROCESS (proc));
1045 else 1030 else
1046 event_stream_select_process (XPROCESS (proc)); 1031 event_stream_select_process (XPROCESS (proc));
1047 } 1032 }
1072 { 1057 {
1073 CHECK_PROCESS (proc); 1058 CHECK_PROCESS (proc);
1074 return XPROCESS (proc)->filter; 1059 return XPROCESS (proc)->filter;
1075 } 1060 }
1076 1061
1077 DEFUN ("process-send-region", Fprocess_send_region, 3, 4, 0, /* 1062 DEFUN ("process-send-region", Fprocess_send_region, 3, 3, 0, /*
1078 Send current contents of the region between START and END as input to PROCESS. 1063 Send current contents of region as input to PROCESS.
1079 PROCESS may be a process name or an actual process. 1064 PROCESS may be a process name or an actual process.
1080 BUFFER specifies the buffer to look in; if nil, the current buffer is used. 1065 Called from program, takes three arguments, PROCESS, START and END.
1081 If the region is more than 500 or so characters long, 1066 If the region is more than 500 or so characters long,
1082 it is sent in several bunches. This may happen even for shorter regions. 1067 it is sent in several bunches. This may happen even for shorter regions.
1083 Output from processes can arrive in between bunches. 1068 Output from processes can arrive in between bunches.
1084 */ 1069 */
1085 (process, start, end, buffer)) 1070 (process, start, end))
1086 { 1071 {
1087 /* This function can GC */ 1072 /* This function can GC */
1088 Lisp_Object proc = get_process (process); 1073 Lisp_Object proc = get_process (process);
1089 Bufpos st, en; 1074 Bufpos st, en;
1090 struct buffer *buf = decode_buffer (buffer, 0); 1075
1091 1076 get_buffer_range_char (current_buffer, start, end, &st, &en, 0);
1092 XSETBUFFER (buffer, buf); 1077
1093 get_buffer_range_char (buf, start, end, &st, &en, 0); 1078 send_process (proc, Fcurrent_buffer (), 0,
1094 1079 st, en - st);
1095 send_process (proc, buffer, 0, st, en - st);
1096 return Qnil; 1080 return Qnil;
1097 } 1081 }
1098 1082
1099 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /* 1083 DEFUN ("process-send-string", Fprocess_send_string, 2, 4, 0, /*
1100 Send PROCESS the contents of STRING as input. 1084 Send PROCESS the contents of STRING as input.
1127 Return PROCESS's input coding system. 1111 Return PROCESS's input coding system.
1128 */ 1112 */
1129 (process)) 1113 (process))
1130 { 1114 {
1131 process = get_process (process); 1115 process = get_process (process);
1132 CHECK_LIVE_PROCESS (process);
1133 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); 1116 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) );
1134 } 1117 }
1135 1118
1136 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* 1119 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /*
1137 Return PROCESS's output coding system. 1120 Return PROCESS's output coding system.
1138 */ 1121 */
1139 (process)) 1122 (process))
1140 { 1123 {
1141 process = get_process (process); 1124 process = get_process (process);
1142 CHECK_LIVE_PROCESS (process);
1143 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); 1125 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream));
1144 } 1126 }
1145 1127
1146 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* 1128 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /*
1147 Return a pair of coding-system for decoding and encoding of PROCESS. 1129 Return a pair of coding-system for decoding and encoding of PROCESS.
1148 */ 1130 */
1149 (process)) 1131 (process))
1150 { 1132 {
1151 process = get_process (process); 1133 process = get_process (process);
1152 CHECK_LIVE_PROCESS (process);
1153 return Fcons (decoding_stream_coding_system 1134 return Fcons (decoding_stream_coding_system
1154 (XLSTREAM (XPROCESS (process)->coding_instream)), 1135 (XLSTREAM (XPROCESS (process)->coding_instream)),
1155 encoding_stream_coding_system 1136 encoding_stream_coding_system
1156 (XLSTREAM (XPROCESS (process)->coding_outstream))); 1137 (XLSTREAM (XPROCESS (process)->coding_outstream)));
1157 } 1138 }
1162 */ 1143 */
1163 (process, codesys)) 1144 (process, codesys))
1164 { 1145 {
1165 codesys = Fget_coding_system (codesys); 1146 codesys = Fget_coding_system (codesys);
1166 process = get_process (process); 1147 process = get_process (process);
1167 CHECK_LIVE_PROCESS (process);
1168
1169 set_decoding_stream_coding_system 1148 set_decoding_stream_coding_system
1170 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); 1149 (XLSTREAM (XPROCESS (process)->coding_instream), codesys);
1171 return Qnil; 1150 return Qnil;
1172 } 1151 }
1173 1152
1177 */ 1156 */
1178 (process, codesys)) 1157 (process, codesys))
1179 { 1158 {
1180 codesys = Fget_coding_system (codesys); 1159 codesys = Fget_coding_system (codesys);
1181 process = get_process (process); 1160 process = get_process (process);
1182 CHECK_LIVE_PROCESS (process);
1183
1184 set_encoding_stream_coding_system 1161 set_encoding_stream_coding_system
1185 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); 1162 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys);
1186 return Qnil; 1163 return Qnil;
1187 } 1164 }
1188 1165
1189 DEFUN ("set-process-coding-system", Fset_process_coding_system, 1166 DEFUN ("set-process-coding-system", Fset_process_coding_system,
1190 1, 3, 0, /* 1167 1, 3, 0, /*
1191 Set coding-systems of PROCESS to DECODING and ENCODING. 1168 Set coding-systems of PROCESS to DECODING and ENCODING.
1192 DECODING will be used to decode subprocess output and ENCODING to
1193 encode subprocess input.
1194 */ 1169 */
1195 (process, decoding, encoding)) 1170 (process, decoding, encoding))
1196 { 1171 {
1197 if (!NILP (decoding)) 1172 if (!NILP (decoding))
1198 Fset_process_input_coding_system (process, decoding); 1173 Fset_process_input_coding_system (process, decoding);
1210 /************************************************************************/ 1185 /************************************************************************/
1211 1186
1212 static Lisp_Object 1187 static Lisp_Object
1213 exec_sentinel_unwind (Lisp_Object datum) 1188 exec_sentinel_unwind (Lisp_Object datum)
1214 { 1189 {
1215 Lisp_Cons *d = XCONS (datum); 1190 struct Lisp_Cons *d = XCONS (datum);
1216 XPROCESS (d->car)->sentinel = d->cdr; 1191 XPROCESS (d->car)->sentinel = d->cdr;
1217 free_cons (d); 1192 free_cons (d);
1218 return Qnil; 1193 return Qnil;
1219 } 1194 }
1220 1195
1221 static void 1196 static void
1222 exec_sentinel (Lisp_Object proc, Lisp_Object reason) 1197 exec_sentinel (Lisp_Object proc, Lisp_Object reason)
1223 { 1198 {
1224 /* This function can GC */ 1199 /* This function can GC */
1225 int speccount = specpdl_depth (); 1200 int speccount = specpdl_depth ();
1226 Lisp_Process *p = XPROCESS (proc); 1201 struct Lisp_Process *p = XPROCESS (proc);
1227 Lisp_Object sentinel = p->sentinel; 1202 Lisp_Object sentinel = p->sentinel;
1228 1203
1229 if (NILP (sentinel)) 1204 if (NILP (sentinel))
1230 return; 1205 return;
1231 1206
1266 CHECK_PROCESS (proc); 1241 CHECK_PROCESS (proc);
1267 return XPROCESS (proc)->sentinel; 1242 return XPROCESS (proc)->sentinel;
1268 } 1243 }
1269 1244
1270 1245
1271 const char * 1246 CONST char *
1272 signal_name (int signum) 1247 signal_name (int signum)
1273 { 1248 {
1274 if (signum >= 0 && signum < NSIG) 1249 if (signum >= 0 && signum < NSIG)
1275 return (const char *) sys_siglist[signum]; 1250 return (CONST char *) sys_siglist[signum];
1276 1251
1277 return (const char *) GETTEXT ("unknown signal"); 1252 return (CONST char *) GETTEXT ("unknown signal");
1278 } 1253 }
1279 1254
1280 void 1255 void
1281 update_process_status (Lisp_Object p, 1256 update_process_status (Lisp_Object p,
1282 Lisp_Object status_symbol, 1257 Lisp_Object status_symbol,
1291 } 1266 }
1292 1267
1293 /* Return a string describing a process status list. */ 1268 /* Return a string describing a process status list. */
1294 1269
1295 static Lisp_Object 1270 static Lisp_Object
1296 status_message (Lisp_Process *p) 1271 status_message (struct Lisp_Process *p)
1297 { 1272 {
1298 Lisp_Object symbol = p->status_symbol; 1273 Lisp_Object symbol = p->status_symbol;
1299 int code = p->exit_code; 1274 int code = p->exit_code;
1300 int coredump = p->core_dumped; 1275 int coredump = p->core_dumped;
1301 Lisp_Object string, string2; 1276 Lisp_Object string, string2;
1375 GCPRO3 (tail, symbol, msg); 1350 GCPRO3 (tail, symbol, msg);
1376 1351
1377 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail)) 1352 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail))
1378 { 1353 {
1379 Lisp_Object proc = XCAR (tail); 1354 Lisp_Object proc = XCAR (tail);
1380 Lisp_Process *p = XPROCESS (proc); 1355 struct Lisp_Process *p = XPROCESS (proc);
1381 /* p->tick is also volatile. Same thing as above applies. */ 1356 /* p->tick is also volatile. Same thing as above applies. */
1382 int this_process_tick; 1357 int this_process_tick;
1383 1358
1384 /* #### extra check for terminated processes, in case a SIGCHLD 1359 /* #### extra check for terminated processes, in case a SIGCHLD
1385 got missed (this seems to happen sometimes, I'm not sure why). 1360 got missed (this seems to happen sometimes, I'm not sure why).
1542 Lisp_Object proc = get_process (process); 1517 Lisp_Object proc = get_process (process);
1543 1518
1544 if (network_connection_p (proc)) 1519 if (network_connection_p (proc))
1545 error ("Network connection %s is not a subprocess", 1520 error ("Network connection %s is not a subprocess",
1546 XSTRING_DATA (XPROCESS(proc)->name)); 1521 XSTRING_DATA (XPROCESS(proc)->name));
1547 CHECK_LIVE_PROCESS (proc); 1522 if (!PROCESS_LIVE_P (proc))
1523 error ("Process %s is not active",
1524 XSTRING_DATA (XPROCESS(proc)->name));
1548 1525
1549 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg)); 1526 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg));
1550 } 1527 }
1551 1528
1552 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /* 1529 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /*
1643 1620
1644 CHECK_SYMBOL (sigcode); 1621 CHECK_SYMBOL (sigcode);
1645 name = string_data (XSYMBOL (sigcode)->name); 1622 name = string_data (XSYMBOL (sigcode)->name);
1646 1623
1647 #define handle_signal(signal) \ 1624 #define handle_signal(signal) \
1648 else if (!strcmp ((const char *) name, #signal)) \ 1625 else if (!strcmp ((CONST char *) name, #signal)) \
1649 XSETINT (sigcode, signal) 1626 XSETINT (sigcode, signal)
1650 1627
1651 if (0) 1628 if (0)
1652 ; 1629 ;
1653 handle_signal (SIGINT); /* ANSI */ 1630 handle_signal (SIGINT); /* ANSI */
1832 /************************************************************************/ 1809 /************************************************************************/
1833 1810
1834 void 1811 void
1835 deactivate_process (Lisp_Object proc) 1812 deactivate_process (Lisp_Object proc)
1836 { 1813 {
1837 Lisp_Process *p = XPROCESS (proc); 1814 struct Lisp_Process *p = XPROCESS (proc);
1838 USID usid; 1815 USID usid;
1839 1816
1840 /* It's possible that we got as far in the process-creation 1817 /* It's possible that we got as far in the process-creation
1841 process as creating the descriptors but didn't get so 1818 process as creating the descriptors but didn't get so
1842 far as selecting the process for input. In this 1819 far as selecting the process for input. In this
1859 else 1836 else
1860 usid = event_stream_delete_stream_pair (p->pipe_instream, 1837 usid = event_stream_delete_stream_pair (p->pipe_instream,
1861 p->pipe_outstream); 1838 p->pipe_outstream);
1862 1839
1863 if (usid != USID_DONTHASH) 1840 if (usid != USID_DONTHASH)
1864 remhash ((const void*)usid, usid_to_process); 1841 remhash ((CONST void*)usid, usid_to_process);
1865 1842
1866 p->pipe_instream = Qnil; 1843 p->pipe_instream = Qnil;
1867 p->pipe_outstream = Qnil; 1844 p->pipe_outstream = Qnil;
1868 #ifdef FILE_CODING 1845 #ifdef FILE_CODING
1869 p->coding_instream = Qnil; 1846 p->coding_instream = Qnil;
1885 PROCESS may be a process or the name of one, or a buffer name. 1862 PROCESS may be a process or the name of one, or a buffer name.
1886 */ 1863 */
1887 (proc)) 1864 (proc))
1888 { 1865 {
1889 /* This function can GC */ 1866 /* This function can GC */
1890 Lisp_Process *p; 1867 struct Lisp_Process *p;
1891 proc = get_process (proc); 1868 proc = get_process (proc);
1892 p = XPROCESS (proc); 1869 p = XPROCESS (proc);
1893 if (network_connection_p (proc)) 1870 if (network_connection_p (proc))
1894 { 1871 {
1895 p->status_symbol = Qexit; 1872 p->status_symbol = Qexit;
1896 p->exit_code = 0; 1873 p->exit_code = 0;
1897 p->core_dumped = 0; 1874 p->core_dumped = 0;
1898 p->tick++; 1875 p->tick++;
1899 process_tick++; 1876 process_tick++;
1900 } 1877 }
1901 else if (PROCESS_LIVE_P (p)) 1878 else if (!NILP(p->pipe_instream))
1902 { 1879 {
1903 Fkill_process (proc, Qnil); 1880 Fkill_process (proc, Qnil);
1904 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 1881 /* Do this now, since remove_process will make sigchld_handler do nothing. */
1905 p->status_symbol = Qsignal; 1882 p->status_symbol = Qsignal;
1906 p->exit_code = SIGKILL; 1883 p->exit_code = SIGKILL;
1919 void 1896 void
1920 kill_buffer_processes (Lisp_Object buffer) 1897 kill_buffer_processes (Lisp_Object buffer)
1921 { 1898 {
1922 Lisp_Object tail; 1899 Lisp_Object tail;
1923 1900
1924 for (tail = Vprocess_list; CONSP (tail); 1901 for (tail = Vprocess_list; GC_CONSP (tail);
1925 tail = XCDR (tail)) 1902 tail = XCDR (tail))
1926 { 1903 {
1927 Lisp_Object proc = XCAR (tail); 1904 Lisp_Object proc = XCAR (tail);
1928 if (PROCESSP (proc) 1905 if (GC_PROCESSP (proc)
1929 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) 1906 && (GC_NILP (buffer) || GC_EQ (XPROCESS (proc)->buffer, buffer)))
1930 { 1907 {
1931 if (network_connection_p (proc)) 1908 if (network_connection_p (proc))
1932 Fdelete_process (proc); 1909 Fdelete_process (proc);
1933 else if (PROCESS_LIVE_P (XPROCESS (proc))) 1910 else if (!NILP (XPROCESS (proc)->pipe_instream))
1934 process_send_signal (proc, SIGHUP, 0, 1); 1911 process_send_signal (proc, SIGHUP, 0, 1);
1935 } 1912 }
1936 } 1913 }
1937 } 1914 }
1938 1915
1990 #endif /* 0 */ 1967 #endif /* 0 */
1991 1968
1992 void 1969 void
1993 syms_of_process (void) 1970 syms_of_process (void)
1994 { 1971 {
1995 INIT_LRECORD_IMPLEMENTATION (process);
1996
1997 defsymbol (&Qprocessp, "processp"); 1972 defsymbol (&Qprocessp, "processp");
1998 defsymbol (&Qprocess_live_p, "process-live-p");
1999 defsymbol (&Qrun, "run"); 1973 defsymbol (&Qrun, "run");
2000 defsymbol (&Qstop, "stop"); 1974 defsymbol (&Qstop, "stop");
2001 defsymbol (&Qopen, "open"); 1975 defsymbol (&Qopen, "open");
2002 defsymbol (&Qclosed, "closed"); 1976 defsymbol (&Qclosed, "closed");
2003 1977
2004 defsymbol (&Qtcp, "tcp"); 1978 defsymbol (&Qtcpip, "tcp/ip");
2005 defsymbol (&Qudp, "udp");
2006 1979
2007 #ifdef HAVE_MULTICAST 1980 #ifdef HAVE_MULTICAST
2008 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ 1981 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */
2009 #endif 1982 #endif
2010 1983
2011 DEFSUBR (Fprocessp); 1984 DEFSUBR (Fprocessp);
2012 DEFSUBR (Fprocess_live_p);
2013 DEFSUBR (Fget_process); 1985 DEFSUBR (Fget_process);
2014 DEFSUBR (Fget_buffer_process); 1986 DEFSUBR (Fget_buffer_process);
2015 DEFSUBR (Fdelete_process); 1987 DEFSUBR (Fdelete_process);
2016 DEFSUBR (Fprocess_status); 1988 DEFSUBR (Fprocess_status);
2017 DEFSUBR (Fprocess_exit_status); 1989 DEFSUBR (Fprocess_exit_status);
2074 nil means don't delete them until `list-processes' is run. 2046 nil means don't delete them until `list-processes' is run.
2075 */ ); 2047 */ );
2076 2048
2077 delete_exited_processes = 1; 2049 delete_exited_processes = 1;
2078 2050
2079 DEFVAR_CONST_LISP ("null-device", &Vnull_device /*
2080 Name of the null device, which differs from system to system.
2081 The null device is a filename that acts as a sink for arbitrary amounts of
2082 data, which is discarded, or as a source for a zero-length file.
2083 It is available on all the systems that we currently support, but with
2084 different names (typically either `/dev/null' or `nul').
2085
2086 Note that there is also a /dev/zero on most modern Unix versions (including
2087 Cygwin), which acts like /dev/null when used as a sink, but as a source
2088 it sends a non-ending stream of zero bytes. It's used most often along
2089 with memory-mapping. We don't provide a Lisp variable for this because
2090 the operations needing this are lower level than what ELisp programs
2091 typically do, and in any case no equivalent exists under native MS Windows.
2092 */ );
2093 Vnull_device = build_string (NULL_DEVICE);
2094
2095 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /* 2051 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type /*
2096 Control type of device used to communicate with subprocesses. 2052 Control type of device used to communicate with subprocesses.
2097 Values are nil to use a pipe, or t or `pty' to use a pty. 2053 Values are nil to use a pipe, or t or `pty' to use a pty.
2098 The value has no effect if the system has no ptys or if all ptys are busy: 2054 The value has no effect if the system has no ptys or if all ptys are busy:
2099 then a pipe is used in any case. 2055 then a pipe is used in any case.