aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorJoakim Verona2010-08-27 10:58:44 +0200
committerJoakim Verona2010-08-27 10:58:44 +0200
commit362120833bcbbaea94976b6701633e2ed75f6051 (patch)
tree632690a24a934bb51a32303add5172d63b6b9e00 /src/process.c
parent1800c4865b15a9e1154bf1f03d87d1aaf750a527 (diff)
parent1a868076f51b5d6f1cf78117463e6f9c614551ec (diff)
downloademacs-362120833bcbbaea94976b6701633e2ed75f6051.tar.gz
emacs-362120833bcbbaea94976b6701633e2ed75f6051.zip
merge from trunk, fix conflicts
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c1711
1 files changed, 655 insertions, 1056 deletions
diff --git a/src/process.c b/src/process.c
index 22b85ff5910..f348dca7d35 100644
--- a/src/process.c
+++ b/src/process.c
@@ -21,17 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <signal.h> 23#include <signal.h>
24
25/* This file is split into two parts by the following preprocessor
26 conditional. The 'then' clause contains all of the support for
27 asynchronous subprocesses. The 'else' clause contains stub
28 versions of some of the asynchronous subprocess routines that are
29 often called elsewhere in Emacs, so we don't have to #ifdef the
30 sections that call them. */
31
32
33#ifdef subprocesses
34
35#include <stdio.h> 24#include <stdio.h>
36#include <errno.h> 25#include <errno.h>
37#include <setjmp.h> 26#include <setjmp.h>
@@ -42,16 +31,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#ifdef HAVE_INTTYPES_H 31#ifdef HAVE_INTTYPES_H
43#include <inttypes.h> 32#include <inttypes.h>
44#endif 33#endif
45#ifdef STDC_HEADERS
46#include <stdlib.h> 34#include <stdlib.h>
47#endif
48 35
49#ifdef HAVE_UNISTD_H 36#ifdef HAVE_UNISTD_H
50#include <unistd.h> 37#include <unistd.h>
51#endif 38#endif
52#include <fcntl.h> 39#include <fcntl.h>
53 40
54#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ 41/* Only MS-DOS does not define `subprocesses'. */
42#ifdef subprocesses
43
55#include <sys/socket.h> 44#include <sys/socket.h>
56#include <netdb.h> 45#include <netdb.h>
57#include <netinet/in.h> 46#include <netinet/in.h>
@@ -67,30 +56,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
67#include <sys/un.h> 56#include <sys/un.h>
68#endif 57#endif
69#endif 58#endif
70#endif /* HAVE_SOCKETS */
71 59
72#if defined(HAVE_SYS_IOCTL_H) 60#if defined(HAVE_SYS_IOCTL_H)
73#include <sys/ioctl.h> 61#include <sys/ioctl.h>
74#if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) 62#if defined(HAVE_NET_IF_H)
75#include <fcntl.h> 63#include <net/if.h>
76#endif /* HAVE_PTYS and no O_NDELAY */ 64#endif /* HAVE_NET_IF_H */
77#endif /* HAVE_SYS_IOCTL_H */ 65#endif /* HAVE_SYS_IOCTL_H */
78 66
79#ifdef NEED_BSDTTY 67#ifdef NEED_BSDTTY
80#include <bsdtty.h> 68#include <bsdtty.h>
81#endif 69#endif
82 70
83/* Can we use SIOCGIFCONF and/or SIOCGIFADDR */
84#ifdef HAVE_SOCKETS
85#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_NET_IF_H)
86/* sys/ioctl.h may have been included already */
87#ifndef SIOCGIFADDR
88#include <sys/ioctl.h>
89#endif
90#include <net/if.h>
91#endif
92#endif
93
94#ifdef HAVE_SYS_WAIT 71#ifdef HAVE_SYS_WAIT
95#include <sys/wait.h> 72#include <sys/wait.h>
96#endif 73#endif
@@ -101,6 +78,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
101#include <resolv.h> 78#include <resolv.h>
102#endif 79#endif
103 80
81#ifdef HAVE_UTIL_H
82#include <util.h>
83#endif
84
85#endif /* subprocesses */
86
104#include "lisp.h" 87#include "lisp.h"
105#include "systime.h" 88#include "systime.h"
106#include "systty.h" 89#include "systty.h"
@@ -119,10 +102,36 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
119#include "dispextern.h" 102#include "dispextern.h"
120#include "composite.h" 103#include "composite.h"
121#include "atimer.h" 104#include "atimer.h"
105#include "sysselect.h"
106#include "syssignal.h"
107#include "syswait.h"
122 108
123#if defined (USE_GTK) || defined (HAVE_GCONF) 109#if defined (USE_GTK) || defined (HAVE_GCONF)
124#include "xgselect.h" 110#include "xgselect.h"
125#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ 111#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
112#ifdef HAVE_NS
113#include "nsterm.h"
114#endif
115extern int timers_run;
116
117Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
118Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
119Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
120Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
121Lisp_Object QCname, QCtype;
122
123/* Non-zero if keyboard input is on hold, zero otherwise. */
124
125static int kbd_is_on_hold;
126
127/* Nonzero means delete a process right away if it exits. */
128static int delete_exited_processes;
129
130/* Nonzero means don't run process sentinels. This is used
131 when exiting. */
132int inhibit_sentinels;
133
134#ifdef subprocesses
126 135
127Lisp_Object Qprocessp; 136Lisp_Object Qprocessp;
128Lisp_Object Qrun, Qstop, Qsignal; 137Lisp_Object Qrun, Qstop, Qsignal;
@@ -135,7 +144,7 @@ Lisp_Object Qipv6;
135Lisp_Object QCport, QCspeed, QCprocess; 144Lisp_Object QCport, QCspeed, QCprocess;
136Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; 145Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
137Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; 146Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
138Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; 147Lisp_Object QCbuffer, QChost, QCservice;
139Lisp_Object QClocal, QCremote, QCcoding; 148Lisp_Object QClocal, QCremote, QCcoding;
140Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; 149Lisp_Object QCserver, QCnowait, QCnoquery, QCstop;
141Lisp_Object QCsentinel, QClog, QCoptions, QCplist; 150Lisp_Object QCsentinel, QClog, QCoptions, QCplist;
@@ -151,22 +160,10 @@ extern Lisp_Object QCfamily;
151/* QCfilter is defined in keyboard.c. */ 160/* QCfilter is defined in keyboard.c. */
152extern Lisp_Object QCfilter; 161extern Lisp_Object QCfilter;
153 162
154Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
155Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
156Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
157Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
158
159#ifdef HAVE_SOCKETS
160#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) 163#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
161#define NETCONN1_P(p) (EQ ((p)->type, Qnetwork)) 164#define NETCONN1_P(p) (EQ ((p)->type, Qnetwork))
162#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) 165#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
163#define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) 166#define SERIALCONN1_P(p) (EQ ((p)->type, Qserial))
164#else
165#define NETCONN_P(p) 0
166#define NETCONN1_P(p) 0
167#define SERIALCONN_P(p) 0
168#define SERIALCONN1_P(p) 0
169#endif /* HAVE_SOCKETS */
170 167
171/* Define first descriptor number available for subprocesses. */ 168/* Define first descriptor number available for subprocesses. */
172#define FIRST_PROC_DESC 3 169#define FIRST_PROC_DESC 3
@@ -178,22 +175,11 @@ Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
178#define SIGCHLD SIGCLD 175#define SIGCHLD SIGCLD
179#endif /* SIGCLD */ 176#endif /* SIGCLD */
180 177
181#include "syssignal.h" 178extern const char *get_operating_system_release (void);
182
183#include "syswait.h"
184
185extern char *get_operating_system_release ();
186
187/* Serial processes require termios or Windows. */
188#if defined (HAVE_TERMIOS) || defined (WINDOWSNT)
189#define HAVE_SERIAL
190#endif
191 179
192#ifdef HAVE_SERIAL
193/* From sysdep.c or w32.c */ 180/* From sysdep.c or w32.c */
194extern int serial_open (char *port); 181extern int serial_open (char *port);
195extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact); 182extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact);
196#endif
197 183
198#ifndef HAVE_H_ERRNO 184#ifndef HAVE_H_ERRNO
199extern int h_errno; 185extern int h_errno;
@@ -216,7 +202,6 @@ int update_tick;
216#undef NON_BLOCKING_CONNECT 202#undef NON_BLOCKING_CONNECT
217#else 203#else
218#ifndef NON_BLOCKING_CONNECT 204#ifndef NON_BLOCKING_CONNECT
219#ifdef HAVE_SOCKETS
220#ifdef HAVE_SELECT 205#ifdef HAVE_SELECT
221#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) 206#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX)
222#if defined (O_NONBLOCK) || defined (O_NDELAY) 207#if defined (O_NONBLOCK) || defined (O_NDELAY)
@@ -226,7 +211,6 @@ int update_tick;
226#endif /* O_NONBLOCK || O_NDELAY */ 211#endif /* O_NONBLOCK || O_NDELAY */
227#endif /* HAVE_GETPEERNAME || GNU_LINUX */ 212#endif /* HAVE_GETPEERNAME || GNU_LINUX */
228#endif /* HAVE_SELECT */ 213#endif /* HAVE_SELECT */
229#endif /* HAVE_SOCKETS */
230#endif /* NON_BLOCKING_CONNECT */ 214#endif /* NON_BLOCKING_CONNECT */
231#endif /* BROKEN_NON_BLOCKING_CONNECT */ 215#endif /* BROKEN_NON_BLOCKING_CONNECT */
232 216
@@ -239,13 +223,11 @@ int update_tick;
239#undef DATAGRAM_SOCKETS 223#undef DATAGRAM_SOCKETS
240#else 224#else
241#ifndef DATAGRAM_SOCKETS 225#ifndef DATAGRAM_SOCKETS
242#ifdef HAVE_SOCKETS
243#if defined (HAVE_SELECT) || defined (FIONREAD) 226#if defined (HAVE_SELECT) || defined (FIONREAD)
244#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) 227#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE)
245#define DATAGRAM_SOCKETS 228#define DATAGRAM_SOCKETS
246#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */ 229#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
247#endif /* HAVE_SELECT || FIONREAD */ 230#endif /* HAVE_SELECT || FIONREAD */
248#endif /* HAVE_SOCKETS */
249#endif /* DATAGRAM_SOCKETS */ 231#endif /* DATAGRAM_SOCKETS */
250#endif /* BROKEN_DATAGRAM_SOCKETS */ 232#endif /* BROKEN_DATAGRAM_SOCKETS */
251 233
@@ -282,14 +264,11 @@ static Lisp_Object Vprocess_adaptive_read_buffering;
282#define process_output_delay_count 0 264#define process_output_delay_count 0
283#endif 265#endif
284 266
285 267static int keyboard_bit_set (SELECT_TYPE *);
286#include "sysselect.h" 268static void deactivate_process (Lisp_Object);
287 269static void status_notify (struct Lisp_Process *);
288static int keyboard_bit_set P_ ((SELECT_TYPE *)); 270static int read_process_output (Lisp_Object, int);
289static void deactivate_process P_ ((Lisp_Object)); 271static void create_pty (Lisp_Object);
290static void status_notify P_ ((struct Lisp_Process *));
291static int read_process_output P_ ((Lisp_Object, int));
292static void create_pty P_ ((Lisp_Object));
293 272
294/* If we support a window system, turn on the code to poll periodically 273/* If we support a window system, turn on the code to poll periodically
295 to detect C-g. It isn't actually used when doing interrupt input. */ 274 to detect C-g. It isn't actually used when doing interrupt input. */
@@ -297,11 +276,9 @@ static void create_pty P_ ((Lisp_Object));
297#define POLL_FOR_INPUT 276#define POLL_FOR_INPUT
298#endif 277#endif
299 278
300static Lisp_Object get_process (); 279static Lisp_Object get_process (register Lisp_Object name);
301static void exec_sentinel (); 280static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
302 281
303extern int timers_run;
304
305/* Mask of bits indicating the descriptors that we wait for input on. */ 282/* Mask of bits indicating the descriptors that we wait for input on. */
306 283
307static SELECT_TYPE input_wait_mask; 284static SELECT_TYPE input_wait_mask;
@@ -329,9 +306,9 @@ static SELECT_TYPE connect_wait_mask;
329static int num_pending_connects; 306static int num_pending_connects;
330 307
331#define IF_NON_BLOCKING_CONNECT(s) s 308#define IF_NON_BLOCKING_CONNECT(s) s
332#else 309#else /* NON_BLOCKING_CONNECT */
333#define IF_NON_BLOCKING_CONNECT(s) 310#define IF_NON_BLOCKING_CONNECT(s)
334#endif 311#endif /* NON_BLOCKING_CONNECT */
335 312
336/* The largest descriptor currently in use for a process object. */ 313/* The largest descriptor currently in use for a process object. */
337static int max_process_desc; 314static int max_process_desc;
@@ -342,9 +319,6 @@ static int max_keyboard_desc;
342/* The largest descriptor currently in use for gpm mouse input. */ 319/* The largest descriptor currently in use for gpm mouse input. */
343static int max_gpm_desc; 320static int max_gpm_desc;
344 321
345/* Nonzero means delete a process right away if it exits. */
346static int delete_exited_processes;
347
348/* Indexed by descriptor, gives the process (if any) for that descriptor */ 322/* Indexed by descriptor, gives the process (if any) for that descriptor */
349Lisp_Object chan_process[MAXDESC]; 323Lisp_Object chan_process[MAXDESC];
350 324
@@ -380,10 +354,6 @@ struct sockaddr_and_len {
380/* Maximum number of bytes to send to a pty without an eof. */ 354/* Maximum number of bytes to send to a pty without an eof. */
381static int pty_max_bytes; 355static int pty_max_bytes;
382 356
383/* Nonzero means don't run process sentinels. This is used
384 when exiting. */
385int inhibit_sentinels;
386
387#ifdef HAVE_PTYS 357#ifdef HAVE_PTYS
388#ifdef HAVE_PTY_H 358#ifdef HAVE_PTY_H
389#include <pty.h> 359#include <pty.h>
@@ -399,8 +369,7 @@ static char pty_name[24];
399static Lisp_Object status_convert (int); 369static Lisp_Object status_convert (int);
400 370
401static void 371static void
402update_status (p) 372update_status (struct Lisp_Process *p)
403 struct Lisp_Process *p;
404{ 373{
405 eassert (p->raw_status_new); 374 eassert (p->raw_status_new);
406 p->status = status_convert (p->raw_status); 375 p->status = status_convert (p->raw_status);
@@ -429,11 +398,7 @@ status_convert (int w)
429 and store them individually through the three pointers. */ 398 and store them individually through the three pointers. */
430 399
431static void 400static void
432decode_status (l, symbol, code, coredump) 401decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, int *coredump)
433 Lisp_Object l;
434 Lisp_Object *symbol;
435 int *code;
436 int *coredump;
437{ 402{
438 Lisp_Object tem; 403 Lisp_Object tem;
439 404
@@ -456,8 +421,7 @@ decode_status (l, symbol, code, coredump)
456/* Return a string describing a process status list. */ 421/* Return a string describing a process status list. */
457 422
458static Lisp_Object 423static Lisp_Object
459status_message (p) 424status_message (struct Lisp_Process *p)
460 struct Lisp_Process *p;
461{ 425{
462 Lisp_Object status = p->status; 426 Lisp_Object status = p->status;
463 Lisp_Object symbol; 427 Lisp_Object symbol;
@@ -519,7 +483,7 @@ status_message (p)
519 is left in the variable pty_name. */ 483 is left in the variable pty_name. */
520 484
521static int 485static int
522allocate_pty () 486allocate_pty (void)
523{ 487{
524 register int c, i; 488 register int c, i;
525 int fd; 489 int fd;
@@ -593,8 +557,7 @@ allocate_pty ()
593#endif /* HAVE_PTYS */ 557#endif /* HAVE_PTYS */
594 558
595static Lisp_Object 559static Lisp_Object
596make_process (name) 560make_process (Lisp_Object name)
597 Lisp_Object name;
598{ 561{
599 register Lisp_Object val, tem, name1; 562 register Lisp_Object val, tem, name1;
600 register struct Lisp_Process *p; 563 register struct Lisp_Process *p;
@@ -638,8 +601,7 @@ make_process (name)
638} 601}
639 602
640static void 603static void
641remove_process (proc) 604remove_process (register Lisp_Object proc)
642 register Lisp_Object proc;
643{ 605{
644 register Lisp_Object pair; 606 register Lisp_Object pair;
645 607
@@ -649,52 +611,17 @@ remove_process (proc)
649 deactivate_process (proc); 611 deactivate_process (proc);
650} 612}
651 613
652/* Setup coding systems of PROCESS. */
653
654void
655setup_process_coding_systems (process)
656 Lisp_Object process;
657{
658 struct Lisp_Process *p = XPROCESS (process);
659 int inch = p->infd;
660 int outch = p->outfd;
661 Lisp_Object coding_system;
662
663 if (inch < 0 || outch < 0)
664 return;
665
666 if (!proc_decode_coding_system[inch])
667 proc_decode_coding_system[inch]
668 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
669 coding_system = p->decode_coding_system;
670 if (! NILP (p->filter))
671 ;
672 else if (BUFFERP (p->buffer))
673 {
674 if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
675 coding_system = raw_text_coding_system (coding_system);
676 }
677 setup_coding_system (coding_system, proc_decode_coding_system[inch]);
678
679 if (!proc_encode_coding_system[outch])
680 proc_encode_coding_system[outch]
681 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
682 setup_coding_system (p->encode_coding_system,
683 proc_encode_coding_system[outch]);
684}
685 614
686DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, 615DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
687 doc: /* Return t if OBJECT is a process. */) 616 doc: /* Return t if OBJECT is a process. */)
688 (object) 617 (Lisp_Object object)
689 Lisp_Object object;
690{ 618{
691 return PROCESSP (object) ? Qt : Qnil; 619 return PROCESSP (object) ? Qt : Qnil;
692} 620}
693 621
694DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0, 622DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0,
695 doc: /* Return the process named NAME, or nil if there is none. */) 623 doc: /* Return the process named NAME, or nil if there is none. */)
696 (name) 624 (register Lisp_Object name)
697 register Lisp_Object name;
698{ 625{
699 if (PROCESSP (name)) 626 if (PROCESSP (name))
700 return name; 627 return name;
@@ -702,35 +629,13 @@ DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0,
702 return Fcdr (Fassoc (name, Vprocess_alist)); 629 return Fcdr (Fassoc (name, Vprocess_alist));
703} 630}
704 631
705DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
706 doc: /* Return the (or a) process associated with BUFFER.
707BUFFER may be a buffer or the name of one. */)
708 (buffer)
709 register Lisp_Object buffer;
710{
711 register Lisp_Object buf, tail, proc;
712
713 if (NILP (buffer)) return Qnil;
714 buf = Fget_buffer (buffer);
715 if (NILP (buf)) return Qnil;
716
717 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
718 {
719 proc = Fcdr (XCAR (tail));
720 if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
721 return proc;
722 }
723 return Qnil;
724}
725
726/* This is how commands for the user decode process arguments. It 632/* This is how commands for the user decode process arguments. It
727 accepts a process, a process name, a buffer, a buffer name, or nil. 633 accepts a process, a process name, a buffer, a buffer name, or nil.
728 Buffers denote the first process in the buffer, and nil denotes the 634 Buffers denote the first process in the buffer, and nil denotes the
729 current buffer. */ 635 current buffer. */
730 636
731static Lisp_Object 637static Lisp_Object
732get_process (name) 638get_process (register Lisp_Object name)
733 register Lisp_Object name;
734{ 639{
735 register Lisp_Object proc, obj; 640 register Lisp_Object proc, obj;
736 if (STRINGP (name)) 641 if (STRINGP (name))
@@ -776,8 +681,7 @@ DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
776 doc: /* Delete PROCESS: kill it and forget about it immediately. 681 doc: /* Delete PROCESS: kill it and forget about it immediately.
777PROCESS may be a process, a buffer, the name of a process or buffer, or 682PROCESS may be a process, a buffer, the name of a process or buffer, or
778nil, indicating the current buffer's process. */) 683nil, indicating the current buffer's process. */)
779 (process) 684 (register Lisp_Object process)
780 register Lisp_Object process;
781{ 685{
782 register struct Lisp_Process *p; 686 register struct Lisp_Process *p;
783 687
@@ -844,8 +748,7 @@ failed -- when a non-blocking connection has failed.
844nil -- if arg is a process name and no such process exists. 748nil -- if arg is a process name and no such process exists.
845PROCESS may be a process, a buffer, the name of a process, or 749PROCESS may be a process, a buffer, the name of a process, or
846nil, indicating the current buffer's process. */) 750nil, indicating the current buffer's process. */)
847 (process) 751 (register Lisp_Object process)
848 register Lisp_Object process;
849{ 752{
850 register struct Lisp_Process *p; 753 register struct Lisp_Process *p;
851 register Lisp_Object status; 754 register Lisp_Object status;
@@ -880,8 +783,7 @@ DEFUN ("process-exit-status", Fprocess_exit_status, Sprocess_exit_status,
880 1, 1, 0, 783 1, 1, 0,
881 doc: /* Return the exit status of PROCESS or the signal number that killed it. 784 doc: /* Return the exit status of PROCESS or the signal number that killed it.
882If PROCESS has not yet exited or died, return 0. */) 785If PROCESS has not yet exited or died, return 0. */)
883 (process) 786 (register Lisp_Object process)
884 register Lisp_Object process;
885{ 787{
886 CHECK_PROCESS (process); 788 CHECK_PROCESS (process);
887 if (XPROCESS (process)->raw_status_new) 789 if (XPROCESS (process)->raw_status_new)
@@ -895,8 +797,7 @@ DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0,
895 doc: /* Return the process id of PROCESS. 797 doc: /* Return the process id of PROCESS.
896This is the pid of the external process which PROCESS uses or talks to. 798This is the pid of the external process which PROCESS uses or talks to.
897For a network connection, this value is nil. */) 799For a network connection, this value is nil. */)
898 (process) 800 (register Lisp_Object process)
899 register Lisp_Object process;
900{ 801{
901 /* Assignment to EMACS_INT stops GCC whining about limited range of 802 /* Assignment to EMACS_INT stops GCC whining about limited range of
902 data type. */ 803 data type. */
@@ -911,8 +812,7 @@ DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0,
911 doc: /* Return the name of PROCESS, as a string. 812 doc: /* Return the name of PROCESS, as a string.
912This is the name of the program invoked in PROCESS, 813This is the name of the program invoked in PROCESS,
913possibly modified to make it unique among process names. */) 814possibly modified to make it unique among process names. */)
914 (process) 815 (register Lisp_Object process)
915 register Lisp_Object process;
916{ 816{
917 CHECK_PROCESS (process); 817 CHECK_PROCESS (process);
918 return XPROCESS (process)->name; 818 return XPROCESS (process)->name;
@@ -924,8 +824,7 @@ This is a list of strings, the first string being the program executed
924and the rest of the strings being the arguments given to it. 824and the rest of the strings being the arguments given to it.
925For a network or serial process, this is nil (process is running) or t 825For a network or serial process, this is nil (process is running) or t
926\(process is stopped). */) 826\(process is stopped). */)
927 (process) 827 (register Lisp_Object process)
928 register Lisp_Object process;
929{ 828{
930 CHECK_PROCESS (process); 829 CHECK_PROCESS (process);
931 return XPROCESS (process)->command; 830 return XPROCESS (process)->command;
@@ -935,8 +834,7 @@ DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0,
935 doc: /* Return the name of the terminal PROCESS uses, or nil if none. 834 doc: /* Return the name of the terminal PROCESS uses, or nil if none.
936This is the terminal that the process itself reads and writes on, 835This is the terminal that the process itself reads and writes on,
937not the name of the pty that Emacs uses to talk with that terminal. */) 836not the name of the pty that Emacs uses to talk with that terminal. */)
938 (process) 837 (register Lisp_Object process)
939 register Lisp_Object process;
940{ 838{
941 CHECK_PROCESS (process); 839 CHECK_PROCESS (process);
942 return XPROCESS (process)->tty_name; 840 return XPROCESS (process)->tty_name;
@@ -945,8 +843,7 @@ not the name of the pty that Emacs uses to talk with that terminal. */)
945DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, 843DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer,
946 2, 2, 0, 844 2, 2, 0,
947 doc: /* Set buffer associated with PROCESS to BUFFER (a buffer, or nil). */) 845 doc: /* Set buffer associated with PROCESS to BUFFER (a buffer, or nil). */)
948 (process, buffer) 846 (register Lisp_Object process, Lisp_Object buffer)
949 register Lisp_Object process, buffer;
950{ 847{
951 struct Lisp_Process *p; 848 struct Lisp_Process *p;
952 849
@@ -965,8 +862,7 @@ DEFUN ("process-buffer", Fprocess_buffer, Sprocess_buffer,
965 1, 1, 0, 862 1, 1, 0,
966 doc: /* Return the buffer PROCESS is associated with. 863 doc: /* Return the buffer PROCESS is associated with.
967Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */) 864Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */)
968 (process) 865 (register Lisp_Object process)
969 register Lisp_Object process;
970{ 866{
971 CHECK_PROCESS (process); 867 CHECK_PROCESS (process);
972 return XPROCESS (process)->buffer; 868 return XPROCESS (process)->buffer;
@@ -975,8 +871,7 @@ Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */)
975DEFUN ("process-mark", Fprocess_mark, Sprocess_mark, 871DEFUN ("process-mark", Fprocess_mark, Sprocess_mark,
976 1, 1, 0, 872 1, 1, 0,
977 doc: /* Return the marker for the end of the last output from PROCESS. */) 873 doc: /* Return the marker for the end of the last output from PROCESS. */)
978 (process) 874 (register Lisp_Object process)
979 register Lisp_Object process;
980{ 875{
981 CHECK_PROCESS (process); 876 CHECK_PROCESS (process);
982 return XPROCESS (process)->mark; 877 return XPROCESS (process)->mark;
@@ -998,8 +893,7 @@ The string argument is normally a multibyte string, except:
998- if `default-enable-multibyte-characters' is nil, it is a unibyte 893- if `default-enable-multibyte-characters' is nil, it is a unibyte
999 string (the result of converting the decoded input multibyte 894 string (the result of converting the decoded input multibyte
1000 string to unibyte with `string-make-unibyte'). */) 895 string to unibyte with `string-make-unibyte'). */)
1001 (process, filter) 896 (register Lisp_Object process, Lisp_Object filter)
1002 register Lisp_Object process, filter;
1003{ 897{
1004 struct Lisp_Process *p; 898 struct Lisp_Process *p;
1005 899
@@ -1041,8 +935,7 @@ DEFUN ("process-filter", Fprocess_filter, Sprocess_filter,
1041 1, 1, 0, 935 1, 1, 0,
1042 doc: /* Returns the filter function of PROCESS; nil if none. 936 doc: /* Returns the filter function of PROCESS; nil if none.
1043See `set-process-filter' for more info on filter functions. */) 937See `set-process-filter' for more info on filter functions. */)
1044 (process) 938 (register Lisp_Object process)
1045 register Lisp_Object process;
1046{ 939{
1047 CHECK_PROCESS (process); 940 CHECK_PROCESS (process);
1048 return XPROCESS (process)->filter; 941 return XPROCESS (process)->filter;
@@ -1053,8 +946,7 @@ DEFUN ("set-process-sentinel", Fset_process_sentinel, Sset_process_sentinel,
1053 doc: /* Give PROCESS the sentinel SENTINEL; nil for none. 946 doc: /* Give PROCESS the sentinel SENTINEL; nil for none.
1054The sentinel is called as a function when the process changes state. 947The sentinel is called as a function when the process changes state.
1055It gets two arguments: the process, and a string describing the change. */) 948It gets two arguments: the process, and a string describing the change. */)
1056 (process, sentinel) 949 (register Lisp_Object process, Lisp_Object sentinel)
1057 register Lisp_Object process, sentinel;
1058{ 950{
1059 struct Lisp_Process *p; 951 struct Lisp_Process *p;
1060 952
@@ -1071,8 +963,7 @@ DEFUN ("process-sentinel", Fprocess_sentinel, Sprocess_sentinel,
1071 1, 1, 0, 963 1, 1, 0,
1072 doc: /* Return the sentinel of PROCESS; nil if none. 964 doc: /* Return the sentinel of PROCESS; nil if none.
1073See `set-process-sentinel' for more info on sentinels. */) 965See `set-process-sentinel' for more info on sentinels. */)
1074 (process) 966 (register Lisp_Object process)
1075 register Lisp_Object process;
1076{ 967{
1077 CHECK_PROCESS (process); 968 CHECK_PROCESS (process);
1078 return XPROCESS (process)->sentinel; 969 return XPROCESS (process)->sentinel;
@@ -1081,8 +972,7 @@ See `set-process-sentinel' for more info on sentinels. */)
1081DEFUN ("set-process-window-size", Fset_process_window_size, 972DEFUN ("set-process-window-size", Fset_process_window_size,
1082 Sset_process_window_size, 3, 3, 0, 973 Sset_process_window_size, 3, 3, 0,
1083 doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) 974 doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */)
1084 (process, height, width) 975 (register Lisp_Object process, Lisp_Object height, Lisp_Object width)
1085 register Lisp_Object process, height, width;
1086{ 976{
1087 CHECK_PROCESS (process); 977 CHECK_PROCESS (process);
1088 CHECK_NATNUM (height); 978 CHECK_NATNUM (height);
@@ -1113,36 +1003,20 @@ is more appropriate for saving the process buffer.
1113Binding the variable `inherit-process-coding-system' to non-nil before 1003Binding the variable `inherit-process-coding-system' to non-nil before
1114starting the process is an alternative way of setting the inherit flag 1004starting the process is an alternative way of setting the inherit flag
1115for the process which will run. */) 1005for the process which will run. */)
1116 (process, flag) 1006 (register Lisp_Object process, Lisp_Object flag)
1117 register Lisp_Object process, flag;
1118{ 1007{
1119 CHECK_PROCESS (process); 1008 CHECK_PROCESS (process);
1120 XPROCESS (process)->inherit_coding_system_flag = !NILP (flag); 1009 XPROCESS (process)->inherit_coding_system_flag = !NILP (flag);
1121 return flag; 1010 return flag;
1122} 1011}
1123 1012
1124DEFUN ("process-inherit-coding-system-flag",
1125 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
1126 1, 1, 0,
1127 doc: /* Return the value of inherit-coding-system flag for PROCESS.
1128If this flag is t, `buffer-file-coding-system' of the buffer
1129associated with PROCESS will inherit the coding system used to decode
1130the process output. */)
1131 (process)
1132 register Lisp_Object process;
1133{
1134 CHECK_PROCESS (process);
1135 return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil;
1136}
1137
1138DEFUN ("set-process-query-on-exit-flag", 1013DEFUN ("set-process-query-on-exit-flag",
1139 Fset_process_query_on_exit_flag, Sset_process_query_on_exit_flag, 1014 Fset_process_query_on_exit_flag, Sset_process_query_on_exit_flag,
1140 2, 2, 0, 1015 2, 2, 0,
1141 doc: /* Specify if query is needed for PROCESS when Emacs is exited. 1016 doc: /* Specify if query is needed for PROCESS when Emacs is exited.
1142If the second argument FLAG is non-nil, Emacs will query the user before 1017If the second argument FLAG is non-nil, Emacs will query the user before
1143exiting or killing a buffer if PROCESS is running. */) 1018exiting or killing a buffer if PROCESS is running. */)
1144 (process, flag) 1019 (register Lisp_Object process, Lisp_Object flag)
1145 register Lisp_Object process, flag;
1146{ 1020{
1147 CHECK_PROCESS (process); 1021 CHECK_PROCESS (process);
1148 XPROCESS (process)->kill_without_query = NILP (flag); 1022 XPROCESS (process)->kill_without_query = NILP (flag);
@@ -1153,15 +1027,14 @@ DEFUN ("process-query-on-exit-flag",
1153 Fprocess_query_on_exit_flag, Sprocess_query_on_exit_flag, 1027 Fprocess_query_on_exit_flag, Sprocess_query_on_exit_flag,
1154 1, 1, 0, 1028 1, 1, 0,
1155 doc: /* Return the current value of query-on-exit flag for PROCESS. */) 1029 doc: /* Return the current value of query-on-exit flag for PROCESS. */)
1156 (process) 1030 (register Lisp_Object process)
1157 register Lisp_Object process;
1158{ 1031{
1159 CHECK_PROCESS (process); 1032 CHECK_PROCESS (process);
1160 return (XPROCESS (process)->kill_without_query ? Qnil : Qt); 1033 return (XPROCESS (process)->kill_without_query ? Qnil : Qt);
1161} 1034}
1162 1035
1163#ifdef DATAGRAM_SOCKETS 1036#ifdef DATAGRAM_SOCKETS
1164Lisp_Object Fprocess_datagram_address (); 1037Lisp_Object Fprocess_datagram_address (Lisp_Object process);
1165#endif 1038#endif
1166 1039
1167DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, 1040DEFUN ("process-contact", Fprocess_contact, Sprocess_contact,
@@ -1174,8 +1047,7 @@ connection. If KEY is t, the complete contact information for the
1174connection is returned, else the specific value for the keyword KEY is 1047connection is returned, else the specific value for the keyword KEY is
1175returned. See `make-network-process' or `make-serial-process' for a 1048returned. See `make-network-process' or `make-serial-process' for a
1176list of keywords. */) 1049list of keywords. */)
1177 (process, key) 1050 (register Lisp_Object process, Lisp_Object key)
1178 register Lisp_Object process, key;
1179{ 1051{
1180 Lisp_Object contact; 1052 Lisp_Object contact;
1181 1053
@@ -1203,8 +1075,7 @@ list of keywords. */)
1203DEFUN ("process-plist", Fprocess_plist, Sprocess_plist, 1075DEFUN ("process-plist", Fprocess_plist, Sprocess_plist,
1204 1, 1, 0, 1076 1, 1, 0,
1205 doc: /* Return the plist of PROCESS. */) 1077 doc: /* Return the plist of PROCESS. */)
1206 (process) 1078 (register Lisp_Object process)
1207 register Lisp_Object process;
1208{ 1079{
1209 CHECK_PROCESS (process); 1080 CHECK_PROCESS (process);
1210 return XPROCESS (process)->plist; 1081 return XPROCESS (process)->plist;
@@ -1213,8 +1084,7 @@ DEFUN ("process-plist", Fprocess_plist, Sprocess_plist,
1213DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist, 1084DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist,
1214 2, 2, 0, 1085 2, 2, 0,
1215 doc: /* Replace the plist of PROCESS with PLIST. Returns PLIST. */) 1086 doc: /* Replace the plist of PROCESS with PLIST. Returns PLIST. */)
1216 (process, plist) 1087 (register Lisp_Object process, Lisp_Object plist)
1217 register Lisp_Object process, plist;
1218{ 1088{
1219 CHECK_PROCESS (process); 1089 CHECK_PROCESS (process);
1220 CHECK_LIST (plist); 1090 CHECK_LIST (plist);
@@ -1229,8 +1099,7 @@ DEFUN ("process-connection", Fprocess_connection, Sprocess_connection, 1, 1, 0,
1229 doc: /* Return the connection type of PROCESS. 1099 doc: /* Return the connection type of PROCESS.
1230The value is nil for a pipe, t or `pty' for a pty, or `stream' for 1100The value is nil for a pipe, t or `pty' for a pty, or `stream' for
1231a socket connection. */) 1101a socket connection. */)
1232 (process) 1102 (Lisp_Object process)
1233 Lisp_Object process;
1234{ 1103{
1235 return XPROCESS (process)->type; 1104 return XPROCESS (process)->type;
1236} 1105}
@@ -1241,15 +1110,13 @@ DEFUN ("process-type", Fprocess_type, Sprocess_type, 1, 1, 0,
1241The value is either the symbol `real', `network', or `serial'. 1110The value is either the symbol `real', `network', or `serial'.
1242PROCESS may be a process, a buffer, the name of a process or buffer, or 1111PROCESS may be a process, a buffer, the name of a process or buffer, or
1243nil, indicating the current buffer's process. */) 1112nil, indicating the current buffer's process. */)
1244 (process) 1113 (Lisp_Object process)
1245 Lisp_Object process;
1246{ 1114{
1247 Lisp_Object proc; 1115 Lisp_Object proc;
1248 proc = get_process (process); 1116 proc = get_process (process);
1249 return XPROCESS (proc)->type; 1117 return XPROCESS (proc)->type;
1250} 1118}
1251 1119
1252#ifdef HAVE_SOCKETS
1253DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address, 1120DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
1254 1, 2, 0, 1121 1, 2, 0,
1255 doc: /* Convert network ADDRESS from internal format to a string. 1122 doc: /* Convert network ADDRESS from internal format to a string.
@@ -1258,8 +1125,7 @@ An 8 or 9 element vector represents an IPv6 address (with port number).
1258If optional second argument OMIT-PORT is non-nil, don't include a port 1125If optional second argument OMIT-PORT is non-nil, don't include a port
1259number in the string, even when present in ADDRESS. 1126number in the string, even when present in ADDRESS.
1260Returns nil if format of ADDRESS is invalid. */) 1127Returns nil if format of ADDRESS is invalid. */)
1261 (address, omit_port) 1128 (Lisp_Object address, Lisp_Object omit_port)
1262 Lisp_Object address, omit_port;
1263{ 1129{
1264 if (NILP (address)) 1130 if (NILP (address))
1265 return Qnil; 1131 return Qnil;
@@ -1324,11 +1190,9 @@ Returns nil if format of ADDRESS is invalid. */)
1324 1190
1325 return Qnil; 1191 return Qnil;
1326} 1192}
1327#endif
1328 1193
1329static Lisp_Object 1194static Lisp_Object
1330list_processes_1 (query_only) 1195list_processes_1 (Lisp_Object query_only)
1331 Lisp_Object query_only;
1332{ 1196{
1333 register Lisp_Object tail, tem; 1197 register Lisp_Object tail, tem;
1334 Lisp_Object proc, minspace, tem1; 1198 Lisp_Object proc, minspace, tem1;
@@ -1562,8 +1426,7 @@ If optional argument QUERY-ONLY is non-nil, only processes with
1562the query-on-exit flag set will be listed. 1426the query-on-exit flag set will be listed.
1563Any process listed as exited or signaled is actually eliminated 1427Any process listed as exited or signaled is actually eliminated
1564after the listing is made. */) 1428after the listing is made. */)
1565 (query_only) 1429 (Lisp_Object query_only)
1566 Lisp_Object query_only;
1567{ 1430{
1568 internal_with_output_to_temp_buffer ("*Process List*", 1431 internal_with_output_to_temp_buffer ("*Process List*",
1569 list_processes_1, query_only); 1432 list_processes_1, query_only);
@@ -1572,14 +1435,14 @@ after the listing is made. */)
1572 1435
1573DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0, 1436DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0,
1574 doc: /* Return a list of all processes. */) 1437 doc: /* Return a list of all processes. */)
1575 () 1438 (void)
1576{ 1439{
1577 return Fmapcar (Qcdr, Vprocess_alist); 1440 return Fmapcar (Qcdr, Vprocess_alist);
1578} 1441}
1579 1442
1580/* Starting asynchronous inferior processes. */ 1443/* Starting asynchronous inferior processes. */
1581 1444
1582static Lisp_Object start_process_unwind (); 1445static Lisp_Object start_process_unwind (Lisp_Object proc);
1583 1446
1584DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, 1447DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0,
1585 doc: /* Start a program in a subprocess. Return the process object for it. 1448 doc: /* Start a program in a subprocess. Return the process object for it.
@@ -1600,9 +1463,7 @@ the command through a shell and redirect one of them using the shell
1600syntax. 1463syntax.
1601 1464
1602usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) 1465usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1603 (nargs, args) 1466 (int nargs, register Lisp_Object *args)
1604 int nargs;
1605 register Lisp_Object *args;
1606{ 1467{
1607 Lisp_Object buffer, name, program, proc, current_dir, tem; 1468 Lisp_Object buffer, name, program, proc, current_dir, tem;
1608 register unsigned char **new_argv; 1469 register unsigned char **new_argv;
@@ -1814,8 +1675,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1814 an error and the process wasn't started successfully, so we should 1675 an error and the process wasn't started successfully, so we should
1815 remove it from the process list. */ 1676 remove it from the process list. */
1816static Lisp_Object 1677static Lisp_Object
1817start_process_unwind (proc) 1678start_process_unwind (Lisp_Object proc)
1818 Lisp_Object proc;
1819{ 1679{
1820 if (!PROCESSP (proc)) 1680 if (!PROCESSP (proc))
1821 abort (); 1681 abort ();
@@ -1828,37 +1688,14 @@ start_process_unwind (proc)
1828} 1688}
1829 1689
1830static void 1690static void
1831create_process_1 (timer) 1691create_process_1 (struct atimer *timer)
1832 struct atimer *timer;
1833{ 1692{
1834 /* Nothing to do. */ 1693 /* Nothing to do. */
1835} 1694}
1836 1695
1837 1696
1838#if 0 /* This doesn't work; see the note before sigchld_handler. */
1839#ifdef USG
1840#ifdef SIGCHLD
1841/* Mimic blocking of signals on system V, which doesn't really have it. */
1842
1843/* Nonzero means we got a SIGCHLD when it was supposed to be blocked. */
1844int sigchld_deferred;
1845
1846SIGTYPE
1847create_process_sigchld ()
1848{
1849 signal (SIGCHLD, create_process_sigchld);
1850
1851 sigchld_deferred = 1;
1852}
1853#endif
1854#endif
1855#endif
1856
1857void 1697void
1858create_process (process, new_argv, current_dir) 1698create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1859 Lisp_Object process;
1860 char **new_argv;
1861 Lisp_Object current_dir;
1862{ 1699{
1863 int inchannel, outchannel; 1700 int inchannel, outchannel;
1864 pid_t pid; 1701 pid_t pid;
@@ -2038,7 +1875,7 @@ create_process (process, new_argv, current_dir)
2038 process_set_signal to fail on SGI when using a pipe. */ 1875 process_set_signal to fail on SGI when using a pipe. */
2039 setsid (); 1876 setsid ();
2040 /* Make the pty's terminal the controlling terminal. */ 1877 /* Make the pty's terminal the controlling terminal. */
2041 if (pty_flag) 1878 if (pty_flag && xforkin >= 0)
2042 { 1879 {
2043#ifdef TIOCSCTTY 1880#ifdef TIOCSCTTY
2044 /* We ignore the return value 1881 /* We ignore the return value
@@ -2054,7 +1891,7 @@ create_process (process, new_argv, current_dir)
2054 setpgrp (); 1891 setpgrp ();
2055#endif /* USG */ 1892#endif /* USG */
2056#endif /* not HAVE_SETSID */ 1893#endif /* not HAVE_SETSID */
2057#if defined (HAVE_TERMIOS) && defined (LDISC1) 1894#if defined (LDISC1)
2058 if (pty_flag && xforkin >= 0) 1895 if (pty_flag && xforkin >= 0)
2059 { 1896 {
2060 struct termios t; 1897 struct termios t;
@@ -2081,8 +1918,11 @@ create_process (process, new_argv, current_dir)
2081 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? 1918 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here?
2082 I can't test it since I don't have 4.3. */ 1919 I can't test it since I don't have 4.3. */
2083 int j = emacs_open ("/dev/tty", O_RDWR, 0); 1920 int j = emacs_open ("/dev/tty", O_RDWR, 0);
2084 ioctl (j, TIOCNOTTY, 0); 1921 if (j >= 0)
2085 emacs_close (j); 1922 {
1923 ioctl (j, TIOCNOTTY, 0);
1924 emacs_close (j);
1925 }
2086#ifndef USG 1926#ifndef USG
2087 /* In order to get a controlling terminal on some versions 1927 /* In order to get a controlling terminal on some versions
2088 of BSD, it is necessary to put the process in pgrp 0 1928 of BSD, it is necessary to put the process in pgrp 0
@@ -2242,8 +2082,7 @@ create_process (process, new_argv, current_dir)
2242} 2082}
2243 2083
2244void 2084void
2245create_pty (process) 2085create_pty (Lisp_Object process)
2246 Lisp_Object process;
2247{ 2086{
2248 int inchannel, outchannel; 2087 int inchannel, outchannel;
2249 2088
@@ -2324,15 +2163,11 @@ create_pty (process)
2324} 2163}
2325 2164
2326 2165
2327#ifdef HAVE_SOCKETS
2328
2329/* Convert an internal struct sockaddr to a lisp object (vector or string). 2166/* Convert an internal struct sockaddr to a lisp object (vector or string).
2330 The address family of sa is not included in the result. */ 2167 The address family of sa is not included in the result. */
2331 2168
2332static Lisp_Object 2169static Lisp_Object
2333conv_sockaddr_to_lisp (sa, len) 2170conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
2334 struct sockaddr *sa;
2335 int len;
2336{ 2171{
2337 Lisp_Object address; 2172 Lisp_Object address;
2338 int i; 2173 int i;
@@ -2342,7 +2177,7 @@ conv_sockaddr_to_lisp (sa, len)
2342 /* Workaround for a bug in getsockname on BSD: Names bound to 2177 /* Workaround for a bug in getsockname on BSD: Names bound to
2343 sockets in the UNIX domain are inaccessible; getsockname returns 2178 sockets in the UNIX domain are inaccessible; getsockname returns
2344 a zero length name. */ 2179 a zero length name. */
2345 if (len < OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family)) 2180 if (len < offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family))
2346 return empty_unibyte_string; 2181 return empty_unibyte_string;
2347 2182
2348 switch (sa->sa_family) 2183 switch (sa->sa_family)
@@ -2382,7 +2217,7 @@ conv_sockaddr_to_lisp (sa, len)
2382 } 2217 }
2383#endif 2218#endif
2384 default: 2219 default:
2385 len -= OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family); 2220 len -= offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family);
2386 address = Fcons (make_number (sa->sa_family), 2221 address = Fcons (make_number (sa->sa_family),
2387 Fmake_vector (make_number (len), Qnil)); 2222 Fmake_vector (make_number (len), Qnil));
2388 p = XVECTOR (XCDR (address)); 2223 p = XVECTOR (XCDR (address));
@@ -2401,9 +2236,7 @@ conv_sockaddr_to_lisp (sa, len)
2401/* Get family and required size for sockaddr structure to hold ADDRESS. */ 2236/* Get family and required size for sockaddr structure to hold ADDRESS. */
2402 2237
2403static int 2238static int
2404get_lisp_to_sockaddr_size (address, familyp) 2239get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp)
2405 Lisp_Object address;
2406 int *familyp;
2407{ 2240{
2408 register struct Lisp_Vector *p; 2241 register struct Lisp_Vector *p;
2409 2242
@@ -2448,17 +2281,13 @@ get_lisp_to_sockaddr_size (address, familyp)
2448 we return after zeroing *SA. */ 2281 we return after zeroing *SA. */
2449 2282
2450static void 2283static void
2451conv_lisp_to_sockaddr (family, address, sa, len) 2284conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int len)
2452 int family;
2453 Lisp_Object address;
2454 struct sockaddr *sa;
2455 int len;
2456{ 2285{
2457 register struct Lisp_Vector *p; 2286 register struct Lisp_Vector *p;
2458 register unsigned char *cp = NULL; 2287 register unsigned char *cp = NULL;
2459 register int i; 2288 register int i;
2460 2289
2461 bzero (sa, len); 2290 memset (sa, 0, len);
2462 2291
2463 if (VECTORP (address)) 2292 if (VECTORP (address))
2464 { 2293 {
@@ -2522,8 +2351,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
2522DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_address, 2351DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_address,
2523 1, 1, 0, 2352 1, 1, 0,
2524 doc: /* Get the current datagram address associated with PROCESS. */) 2353 doc: /* Get the current datagram address associated with PROCESS. */)
2525 (process) 2354 (Lisp_Object process)
2526 Lisp_Object process;
2527{ 2355{
2528 int channel; 2356 int channel;
2529 2357
@@ -2541,8 +2369,7 @@ DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_proce
2541 2, 2, 0, 2369 2, 2, 0,
2542 doc: /* Set the datagram address for PROCESS to ADDRESS. 2370 doc: /* Set the datagram address for PROCESS to ADDRESS.
2543Returns nil upon error setting address, ADDRESS otherwise. */) 2371Returns nil upon error setting address, ADDRESS otherwise. */)
2544 (process, address) 2372 (Lisp_Object process, Lisp_Object address)
2545 Lisp_Object process, address;
2546{ 2373{
2547 int channel; 2374 int channel;
2548 int family, len; 2375 int family, len;
@@ -2566,7 +2393,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */)
2566static const struct socket_options { 2393static const struct socket_options {
2567 /* The name of this option. Should be lowercase version of option 2394 /* The name of this option. Should be lowercase version of option
2568 name without SO_ prefix. */ 2395 name without SO_ prefix. */
2569 char *name; 2396 const char *name;
2570 /* Option level SOL_... */ 2397 /* Option level SOL_... */
2571 int optlevel; 2398 int optlevel;
2572 /* Option number SO_... */ 2399 /* Option number SO_... */
@@ -2609,9 +2436,7 @@ static const struct socket_options {
2609*/ 2436*/
2610 2437
2611static int 2438static int
2612set_socket_option (s, opt, val) 2439set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
2613 int s;
2614 Lisp_Object opt, val;
2615{ 2440{
2616 char *name; 2441 char *name;
2617 const struct socket_options *sopt; 2442 const struct socket_options *sopt;
@@ -2655,12 +2480,12 @@ set_socket_option (s, opt, val)
2655 /* This is broken, at least in the Linux 2.4 kernel. 2480 /* This is broken, at least in the Linux 2.4 kernel.
2656 To unbind, the arg must be a zero integer, not the empty string. 2481 To unbind, the arg must be a zero integer, not the empty string.
2657 This should work on all systems. KFS. 2003-09-23. */ 2482 This should work on all systems. KFS. 2003-09-23. */
2658 bzero (devname, sizeof devname); 2483 memset (devname, 0, sizeof devname);
2659 if (STRINGP (val)) 2484 if (STRINGP (val))
2660 { 2485 {
2661 char *arg = (char *) SDATA (val); 2486 char *arg = (char *) SDATA (val);
2662 int len = min (strlen (arg), IFNAMSIZ); 2487 int len = min (strlen (arg), IFNAMSIZ);
2663 bcopy (arg, devname, len); 2488 memcpy (devname, arg, len);
2664 } 2489 }
2665 else if (!NILP (val)) 2490 else if (!NILP (val))
2666 error ("Bad option value for %s", name); 2491 error ("Bad option value for %s", name);
@@ -2705,9 +2530,7 @@ DEFUN ("set-network-process-option",
2705See `make-network-process' for a list of options and values. 2530See `make-network-process' for a list of options and values.
2706If optional fourth arg NO-ERROR is non-nil, don't signal an error if 2531If optional fourth arg NO-ERROR is non-nil, don't signal an error if
2707OPTION is not a supported option, return nil instead; otherwise return t. */) 2532OPTION is not a supported option, return nil instead; otherwise return t. */)
2708 (process, option, value, no_error) 2533 (Lisp_Object process, Lisp_Object option, Lisp_Object value, Lisp_Object no_error)
2709 Lisp_Object process, option, value;
2710 Lisp_Object no_error;
2711{ 2534{
2712 int s; 2535 int s;
2713 struct Lisp_Process *p; 2536 struct Lisp_Process *p;
@@ -2734,7 +2557,6 @@ OPTION is not a supported option, return nil instead; otherwise return t. */)
2734} 2557}
2735 2558
2736 2559
2737#ifdef HAVE_SERIAL
2738DEFUN ("serial-process-configure", 2560DEFUN ("serial-process-configure",
2739 Fserial_process_configure, 2561 Fserial_process_configure,
2740 Sserial_process_configure, 2562 Sserial_process_configure,
@@ -2794,9 +2616,7 @@ Examples:
2794\(serial-process-configure :port "\\\\.\\COM13" :bytesize 7) 2616\(serial-process-configure :port "\\\\.\\COM13" :bytesize 7)
2795 2617
2796usage: (serial-process-configure &rest ARGS) */) 2618usage: (serial-process-configure &rest ARGS) */)
2797 (nargs, args) 2619 (int nargs, Lisp_Object *args)
2798 int nargs;
2799 Lisp_Object *args;
2800{ 2620{
2801 struct Lisp_Process *p; 2621 struct Lisp_Process *p;
2802 Lisp_Object contact = Qnil; 2622 Lisp_Object contact = Qnil;
@@ -2913,9 +2733,7 @@ Examples:
2913\(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil) 2733\(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil)
2914 2734
2915usage: (make-serial-process &rest ARGS) */) 2735usage: (make-serial-process &rest ARGS) */)
2916 (nargs, args) 2736 (int nargs, Lisp_Object *args)
2917 int nargs;
2918 Lisp_Object *args;
2919{ 2737{
2920 int fd = -1; 2738 int fd = -1;
2921 Lisp_Object proc, contact, port; 2739 Lisp_Object proc, contact, port;
@@ -3027,14 +2845,13 @@ usage: (make-serial-process &rest ARGS) */)
3027 p->inherit_coding_system_flag 2845 p->inherit_coding_system_flag
3028 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); 2846 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
3029 2847
3030 Fserial_process_configure(nargs, args); 2848 Fserial_process_configure (nargs, args);
3031 2849
3032 specpdl_ptr = specpdl + specpdl_count; 2850 specpdl_ptr = specpdl + specpdl_count;
3033 2851
3034 UNGCPRO; 2852 UNGCPRO;
3035 return proc; 2853 return proc;
3036} 2854}
3037#endif /* HAVE_SERIAL */
3038 2855
3039/* Create a network stream/datagram client/server process. Treated 2856/* Create a network stream/datagram client/server process. Treated
3040 exactly like a normal process when reading and writing. Primary 2857 exactly like a normal process when reading and writing. Primary
@@ -3194,9 +3011,7 @@ The original argument list, modified with the actual connection
3194information, is available via the `process-contact' function. 3011information, is available via the `process-contact' function.
3195 3012
3196usage: (make-network-process &rest ARGS) */) 3013usage: (make-network-process &rest ARGS) */)
3197 (nargs, args) 3014 (int nargs, Lisp_Object *args)
3198 int nargs;
3199 Lisp_Object *args;
3200{ 3015{
3201 Lisp_Object proc; 3016 Lisp_Object proc;
3202 Lisp_Object contact; 3017 Lisp_Object contact;
@@ -3204,7 +3019,8 @@ usage: (make-network-process &rest ARGS) */)
3204#ifdef HAVE_GETADDRINFO 3019#ifdef HAVE_GETADDRINFO
3205 struct addrinfo ai, *res, *lres; 3020 struct addrinfo ai, *res, *lres;
3206 struct addrinfo hints; 3021 struct addrinfo hints;
3207 char *portstring, portbuf[128]; 3022 const char *portstring;
3023 char portbuf[128];
3208#else /* HAVE_GETADDRINFO */ 3024#else /* HAVE_GETADDRINFO */
3209 struct _emacs_addrinfo 3025 struct _emacs_addrinfo
3210 { 3026 {
@@ -3369,7 +3185,7 @@ usage: (make-network-process &rest ARGS) */)
3369 host = Qnil; 3185 host = Qnil;
3370 } 3186 }
3371 CHECK_STRING (service); 3187 CHECK_STRING (service);
3372 bzero (&address_un, sizeof address_un); 3188 memset (&address_un, 0, sizeof address_un);
3373 address_un.sun_family = AF_LOCAL; 3189 address_un.sun_family = AF_LOCAL;
3374 strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path); 3190 strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path);
3375 ai.ai_addr = (struct sockaddr *) &address_un; 3191 ai.ai_addr = (struct sockaddr *) &address_un;
@@ -3425,7 +3241,7 @@ usage: (make-network-process &rest ARGS) */)
3425 ret = getaddrinfo (SDATA (host), portstring, &hints, &res); 3241 ret = getaddrinfo (SDATA (host), portstring, &hints, &res);
3426 if (ret) 3242 if (ret)
3427#ifdef HAVE_GAI_STRERROR 3243#ifdef HAVE_GAI_STRERROR
3428 error ("%s/%s %s", SDATA (host), portstring, gai_strerror(ret)); 3244 error ("%s/%s %s", SDATA (host), portstring, gai_strerror (ret));
3429#else 3245#else
3430 error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret); 3246 error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret);
3431#endif 3247#endif
@@ -3453,7 +3269,7 @@ usage: (make-network-process &rest ARGS) */)
3453 port = svc_info->s_port; 3269 port = svc_info->s_port;
3454 } 3270 }
3455 3271
3456 bzero (&address_in, sizeof address_in); 3272 memset (&address_in, 0, sizeof address_in);
3457 address_in.sin_family = family; 3273 address_in.sin_family = family;
3458 address_in.sin_addr.s_addr = INADDR_ANY; 3274 address_in.sin_addr.s_addr = INADDR_ANY;
3459 address_in.sin_port = port; 3275 address_in.sin_port = port;
@@ -3477,8 +3293,8 @@ usage: (make-network-process &rest ARGS) */)
3477 3293
3478 if (host_info_ptr) 3294 if (host_info_ptr)
3479 { 3295 {
3480 bcopy (host_info_ptr->h_addr, (char *) &address_in.sin_addr, 3296 memcpy (&address_in.sin_addr, host_info_ptr->h_addr,
3481 host_info_ptr->h_length); 3297 host_info_ptr->h_length);
3482 family = host_info_ptr->h_addrtype; 3298 family = host_info_ptr->h_addrtype;
3483 address_in.sin_family = family; 3299 address_in.sin_family = family;
3484 } 3300 }
@@ -3490,8 +3306,8 @@ usage: (make-network-process &rest ARGS) */)
3490 if (numeric_addr == -1) 3306 if (numeric_addr == -1)
3491 error ("Unknown host \"%s\"", SDATA (host)); 3307 error ("Unknown host \"%s\"", SDATA (host));
3492 3308
3493 bcopy ((char *)&numeric_addr, (char *) &address_in.sin_addr, 3309 memcpy (&address_in.sin_addr, &numeric_addr,
3494 sizeof (address_in.sin_addr)); 3310 sizeof (address_in.sin_addr));
3495 } 3311 }
3496 3312
3497 } 3313 }
@@ -3675,7 +3491,7 @@ usage: (make-network-process &rest ARGS) */)
3675 if (is_server) 3491 if (is_server)
3676 { 3492 {
3677 Lisp_Object remote; 3493 Lisp_Object remote;
3678 bzero (datagram_address[s].sa, lres->ai_addrlen); 3494 memset (datagram_address[s].sa, 0, lres->ai_addrlen);
3679 if (remote = Fplist_get (contact, QCremote), !NILP (remote)) 3495 if (remote = Fplist_get (contact, QCremote), !NILP (remote))
3680 { 3496 {
3681 int rfamily, rlen; 3497 int rfamily, rlen;
@@ -3686,7 +3502,7 @@ usage: (make-network-process &rest ARGS) */)
3686 } 3502 }
3687 } 3503 }
3688 else 3504 else
3689 bcopy (lres->ai_addr, datagram_address[s].sa, lres->ai_addrlen); 3505 memcpy (datagram_address[s].sa, lres->ai_addr, lres->ai_addrlen);
3690 } 3506 }
3691#endif 3507#endif
3692 contact = Fplist_put (contact, QCaddress, 3508 contact = Fplist_put (contact, QCaddress,
@@ -3698,7 +3514,7 @@ usage: (make-network-process &rest ARGS) */)
3698 int len1 = sizeof (sa1); 3514 int len1 = sizeof (sa1);
3699 if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) 3515 if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
3700 contact = Fplist_put (contact, QClocal, 3516 contact = Fplist_put (contact, QClocal,
3701 conv_sockaddr_to_lisp (&sa1, len1)); 3517 conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1));
3702 } 3518 }
3703#endif 3519#endif
3704 } 3520 }
@@ -3899,10 +3715,9 @@ usage: (make-network-process &rest ARGS) */)
3899 UNGCPRO; 3715 UNGCPRO;
3900 return proc; 3716 return proc;
3901} 3717}
3902#endif /* HAVE_SOCKETS */
3903 3718
3904 3719
3905#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) 3720#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
3906 3721
3907#ifdef SIOCGIFCONF 3722#ifdef SIOCGIFCONF
3908DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, 3723DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0,
@@ -3910,7 +3725,7 @@ DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_lis
3910Each element is a cons, the car of which is a string containing the 3725Each element is a cons, the car of which is a string containing the
3911interface name, and the cdr is the network address in internal 3726interface name, and the cdr is the network address in internal
3912format; see the description of ADDRESS in `make-network-process'. */) 3727format; see the description of ADDRESS in `make-network-process'. */)
3913 () 3728 (void)
3914{ 3729{
3915 struct ifconf ifconf; 3730 struct ifconf ifconf;
3916 struct ifreq *ifreqs = NULL; 3731 struct ifreq *ifreqs = NULL;
@@ -3924,7 +3739,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3924 3739
3925 again: 3740 again:
3926 ifaces += 25; 3741 ifaces += 25;
3927 buf_size = ifaces * sizeof(ifreqs[0]); 3742 buf_size = ifaces * sizeof (ifreqs[0]);
3928 ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size); 3743 ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size);
3929 if (!ifreqs) 3744 if (!ifreqs)
3930 { 3745 {
@@ -3953,7 +3768,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3953 char namebuf[sizeof (ifq->ifr_name) + 1]; 3768 char namebuf[sizeof (ifq->ifr_name) + 1];
3954 if (ifq->ifr_addr.sa_family != AF_INET) 3769 if (ifq->ifr_addr.sa_family != AF_INET)
3955 continue; 3770 continue;
3956 bcopy (ifq->ifr_name, namebuf, sizeof (ifq->ifr_name)); 3771 memcpy (namebuf, ifq->ifr_name, sizeof (ifq->ifr_name));
3957 namebuf[sizeof (ifq->ifr_name)] = 0; 3772 namebuf[sizeof (ifq->ifr_name)] = 0;
3958 res = Fcons (Fcons (build_string (namebuf), 3773 res = Fcons (Fcons (build_string (namebuf),
3959 conv_sockaddr_to_lisp (&ifq->ifr_addr, 3774 conv_sockaddr_to_lisp (&ifq->ifr_addr,
@@ -4045,8 +3860,7 @@ The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS),
4045where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address, 3860where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address,
4046NETMASK is the layer 3 network mask, HWADDR is the layer 2 addres, and 3861NETMASK is the layer 3 network mask, HWADDR is the layer 2 addres, and
4047FLAGS is the current flags of the interface. */) 3862FLAGS is the current flags of the interface. */)
4048 (ifname) 3863 (Lisp_Object ifname)
4049 Lisp_Object ifname;
4050{ 3864{
4051 struct ifreq rq; 3865 struct ifreq rq;
4052 Lisp_Object res = Qnil; 3866 Lisp_Object res = Qnil;
@@ -4056,7 +3870,7 @@ FLAGS is the current flags of the interface. */)
4056 3870
4057 CHECK_STRING (ifname); 3871 CHECK_STRING (ifname);
4058 3872
4059 bzero (rq.ifr_name, sizeof rq.ifr_name); 3873 memset (rq.ifr_name, 0, sizeof rq.ifr_name);
4060 strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name)); 3874 strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name));
4061 3875
4062 s = socket (AF_INET, SOCK_STREAM, 0); 3876 s = socket (AF_INET, SOCK_STREAM, 0);
@@ -4146,13 +3960,12 @@ FLAGS is the current flags of the interface. */)
4146 return any ? res : Qnil; 3960 return any ? res : Qnil;
4147} 3961}
4148#endif 3962#endif
4149#endif /* HAVE_SOCKETS */ 3963#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
4150 3964
4151/* Turn off input and output for process PROC. */ 3965/* Turn off input and output for process PROC. */
4152 3966
4153void 3967void
4154deactivate_process (proc) 3968deactivate_process (Lisp_Object proc)
4155 Lisp_Object proc;
4156{ 3969{
4157 register int inchannel, outchannel; 3970 register int inchannel, outchannel;
4158 register struct Lisp_Process *p = XPROCESS (proc); 3971 register struct Lisp_Process *p = XPROCESS (proc);
@@ -4212,31 +4025,6 @@ deactivate_process (proc)
4212 } 4025 }
4213} 4026}
4214 4027
4215/* Close all descriptors currently in use for communication
4216 with subprocess. This is used in a newly-forked subprocess
4217 to get rid of irrelevant descriptors. */
4218
4219void
4220close_process_descs ()
4221{
4222#ifndef WINDOWSNT
4223 int i;
4224 for (i = 0; i < MAXDESC; i++)
4225 {
4226 Lisp_Object process;
4227 process = chan_process[i];
4228 if (!NILP (process))
4229 {
4230 int in = XPROCESS (process)->infd;
4231 int out = XPROCESS (process)->outfd;
4232 if (in >= 0)
4233 emacs_close (in);
4234 if (out >= 0 && in != out)
4235 emacs_close (out);
4236 }
4237 }
4238#endif
4239}
4240 4028
4241DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, 4029DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output,
4242 0, 4, 0, 4030 0, 4, 0,
@@ -4255,8 +4043,7 @@ If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
4255from PROCESS, suspending reading output from other processes. 4043from PROCESS, suspending reading output from other processes.
4256If JUST-THIS-ONE is an integer, don't run any timers either. 4044If JUST-THIS-ONE is an integer, don't run any timers either.
4257Return non-nil if we received any output before the timeout expired. */) 4045Return non-nil if we received any output before the timeout expired. */)
4258 (process, seconds, millisec, just_this_one) 4046 (register Lisp_Object process, Lisp_Object seconds, Lisp_Object millisec, Lisp_Object just_this_one)
4259 register Lisp_Object process, seconds, millisec, just_this_one;
4260{ 4047{
4261 int secs, usecs = 0; 4048 int secs, usecs = 0;
4262 4049
@@ -4310,9 +4097,7 @@ Return non-nil if we received any output before the timeout expired. */)
4310static int connect_counter = 0; 4097static int connect_counter = 0;
4311 4098
4312static void 4099static void
4313server_accept_connection (server, channel) 4100server_accept_connection (Lisp_Object server, int channel)
4314 Lisp_Object server;
4315 int channel;
4316{ 4101{
4317 Lisp_Object proc, caller, name, buffer; 4102 Lisp_Object proc, caller, name, buffer;
4318 Lisp_Object contact, host, service; 4103 Lisp_Object contact, host, service;
@@ -4389,7 +4174,7 @@ server_accept_connection (server, channel)
4389 int i; 4174 int i;
4390 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x"); 4175 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x");
4391 for (i = 0; i < 8; i++) 4176 for (i = 0; i < 8; i++)
4392 args[i+1] = make_number (ntohs(ip6[i])); 4177 args[i+1] = make_number (ntohs (ip6[i]));
4393 host = Fformat (9, args); 4178 host = Fformat (9, args);
4394 service = make_number (ntohs (saddr.in.sin_port)); 4179 service = make_number (ntohs (saddr.in.sin_port));
4395 4180
@@ -4528,8 +4313,7 @@ server_accept_connection (server, channel)
4528static int waiting_for_user_input_p; 4313static int waiting_for_user_input_p;
4529 4314
4530static Lisp_Object 4315static Lisp_Object
4531wait_reading_process_output_unwind (data) 4316wait_reading_process_output_unwind (Lisp_Object data)
4532 Lisp_Object data;
4533{ 4317{
4534 waiting_for_user_input_p = XINT (data); 4318 waiting_for_user_input_p = XINT (data);
4535 return Qnil; 4319 return Qnil;
@@ -4537,7 +4321,7 @@ wait_reading_process_output_unwind (data)
4537 4321
4538/* This is here so breakpoints can be put on it. */ 4322/* This is here so breakpoints can be put on it. */
4539static void 4323static void
4540wait_reading_process_output_1 () 4324wait_reading_process_output_1 (void)
4541{ 4325{
4542} 4326}
4543 4327
@@ -4550,10 +4334,7 @@ wait_reading_process_output_1 ()
4550 4334
4551#ifndef select 4335#ifndef select
4552static INLINE int 4336static INLINE int
4553select_wrapper (n, rfd, wfd, xfd, tmo) 4337select_wrapper (int n, fd_set *rfd, fd_set *wfd, fd_set *xfd, struct timeval *tmo)
4554 int n;
4555 SELECT_TYPE *rfd, *wfd, *xfd;
4556 EMACS_TIME *tmo;
4557{ 4338{
4558 return select (n, rfd, wfd, xfd, tmo); 4339 return select (n, rfd, wfd, xfd, tmo);
4559} 4340}
@@ -4598,12 +4379,10 @@ select_wrapper (n, rfd, wfd, xfd, tmo)
4598 Otherwise, return true if we received input from any process. */ 4379 Otherwise, return true if we received input from any process. */
4599 4380
4600int 4381int
4601wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, 4382wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4602 wait_for_cell, wait_proc, just_wait_proc) 4383 int do_display,
4603 int time_limit, microsecs, read_kbd, do_display; 4384 Lisp_Object wait_for_cell,
4604 Lisp_Object wait_for_cell; 4385 struct Lisp_Process *wait_proc, int just_wait_proc)
4605 struct Lisp_Process *wait_proc;
4606 int just_wait_proc;
4607{ 4386{
4608 register int channel, nfds; 4387 register int channel, nfds;
4609 SELECT_TYPE Available; 4388 SELECT_TYPE Available;
@@ -4762,7 +4541,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4762 SELECT_TYPE Ctemp; 4541 SELECT_TYPE Ctemp;
4763#endif 4542#endif
4764 4543
4765 Atemp = input_wait_mask; 4544 if (kbd_on_hold_p ())
4545 FD_ZERO (&Atemp);
4546 else
4547 Atemp = input_wait_mask;
4766 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); 4548 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
4767 4549
4768 EMACS_SET_SECS_USECS (timeout, 0, 0); 4550 EMACS_SET_SECS_USECS (timeout, 0, 0);
@@ -5195,23 +4977,23 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
5195 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. 4977 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
5196 So only use it on systems where it is known to work. */ 4978 So only use it on systems where it is known to work. */
5197 { 4979 {
5198 int xlen = sizeof(xerrno); 4980 int xlen = sizeof (xerrno);
5199 if (getsockopt(channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) 4981 if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
5200 xerrno = errno; 4982 xerrno = errno;
5201 } 4983 }
5202#else 4984#else
5203 { 4985 {
5204 struct sockaddr pname; 4986 struct sockaddr pname;
5205 int pnamelen = sizeof(pname); 4987 int pnamelen = sizeof (pname);
5206 4988
5207 /* If connection failed, getpeername will fail. */ 4989 /* If connection failed, getpeername will fail. */
5208 xerrno = 0; 4990 xerrno = 0;
5209 if (getpeername(channel, &pname, &pnamelen) < 0) 4991 if (getpeername (channel, &pname, &pnamelen) < 0)
5210 { 4992 {
5211 /* Obtain connect failure code through error slippage. */ 4993 /* Obtain connect failure code through error slippage. */
5212 char dummy; 4994 char dummy;
5213 xerrno = errno; 4995 xerrno = errno;
5214 if (errno == ENOTCONN && read(channel, &dummy, 1) < 0) 4996 if (errno == ENOTCONN && read (channel, &dummy, 1) < 0)
5215 xerrno = errno; 4997 xerrno = errno;
5216 } 4998 }
5217 } 4999 }
@@ -5258,15 +5040,13 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
5258/* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */ 5040/* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */
5259 5041
5260static Lisp_Object 5042static Lisp_Object
5261read_process_output_call (fun_and_args) 5043read_process_output_call (Lisp_Object fun_and_args)
5262 Lisp_Object fun_and_args;
5263{ 5044{
5264 return apply1 (XCAR (fun_and_args), XCDR (fun_and_args)); 5045 return apply1 (XCAR (fun_and_args), XCDR (fun_and_args));
5265} 5046}
5266 5047
5267static Lisp_Object 5048static Lisp_Object
5268read_process_output_error_handler (error) 5049read_process_output_error_handler (Lisp_Object error)
5269 Lisp_Object error;
5270{ 5050{
5271 cmd_error_internal (error, "error in process filter: "); 5051 cmd_error_internal (error, "error in process filter: ");
5272 Vinhibit_quit = Qt; 5052 Vinhibit_quit = Qt;
@@ -5287,9 +5067,7 @@ read_process_output_error_handler (error)
5287 for decoding. */ 5067 for decoding. */
5288 5068
5289static int 5069static int
5290read_process_output (proc, channel) 5070read_process_output (Lisp_Object proc, register int channel)
5291 Lisp_Object proc;
5292 register int channel;
5293{ 5071{
5294 register int nbytes; 5072 register int nbytes;
5295 char *chars; 5073 char *chars;
@@ -5305,7 +5083,7 @@ read_process_output (proc, channel)
5305 chars = (char *) alloca (carryover + readmax); 5083 chars = (char *) alloca (carryover + readmax);
5306 if (carryover) 5084 if (carryover)
5307 /* See the comment above. */ 5085 /* See the comment above. */
5308 bcopy (SDATA (p->decoding_buf), chars, carryover); 5086 memcpy (chars, SDATA (p->decoding_buf), carryover);
5309 5087
5310#ifdef DATAGRAM_SOCKETS 5088#ifdef DATAGRAM_SOCKETS
5311 /* We have a working select, so proc_buffered_char is always -1. */ 5089 /* We have a working select, so proc_buffered_char is always -1. */
@@ -5449,8 +5227,8 @@ read_process_output (proc, channel)
5449 { 5227 {
5450 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5228 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5451 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5229 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5452 bcopy (coding->carryover, SDATA (p->decoding_buf), 5230 memcpy (SDATA (p->decoding_buf), coding->carryover,
5453 coding->carryover_bytes); 5231 coding->carryover_bytes);
5454 p->decoding_carryover = coding->carryover_bytes; 5232 p->decoding_carryover = coding->carryover_bytes;
5455 } 5233 }
5456 if (SBYTES (text) > 0) 5234 if (SBYTES (text) > 0)
@@ -5541,8 +5319,8 @@ read_process_output (proc, channel)
5541 { 5319 {
5542 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5320 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5543 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5321 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5544 bcopy (coding->carryover, SDATA (p->decoding_buf), 5322 memcpy (SDATA (p->decoding_buf), coding->carryover,
5545 coding->carryover_bytes); 5323 coding->carryover_bytes);
5546 p->decoding_carryover = coding->carryover_bytes; 5324 p->decoding_carryover = coding->carryover_bytes;
5547 } 5325 }
5548 /* Adjust the multibyteness of TEXT to that of the buffer. */ 5326 /* Adjust the multibyteness of TEXT to that of the buffer. */
@@ -5599,15 +5377,6 @@ read_process_output (proc, channel)
5599 unbind_to (count, Qnil); 5377 unbind_to (count, Qnil);
5600 return nbytes; 5378 return nbytes;
5601} 5379}
5602
5603DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p,
5604 0, 0, 0,
5605 doc: /* Returns non-nil if Emacs is waiting for input from the user.
5606This is intended for use by asynchronous process output filters and sentinels. */)
5607 ()
5608{
5609 return (waiting_for_user_input_p ? Qt : Qnil);
5610}
5611 5380
5612/* Sending data to subprocess */ 5381/* Sending data to subprocess */
5613 5382
@@ -5615,7 +5384,7 @@ jmp_buf send_process_frame;
5615Lisp_Object process_sent_to; 5384Lisp_Object process_sent_to;
5616 5385
5617SIGTYPE 5386SIGTYPE
5618send_process_trap () 5387send_process_trap (int ignore)
5619{ 5388{
5620 SIGNAL_THREAD_CHECK (SIGPIPE); 5389 SIGNAL_THREAD_CHECK (SIGPIPE);
5621 sigunblock (sigmask (SIGPIPE)); 5390 sigunblock (sigmask (SIGPIPE));
@@ -5633,18 +5402,15 @@ send_process_trap ()
5633 This function can evaluate Lisp code and can garbage collect. */ 5402 This function can evaluate Lisp code and can garbage collect. */
5634 5403
5635static void 5404static void
5636send_process (proc, buf, len, object) 5405send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5637 volatile Lisp_Object proc; 5406 volatile int len, volatile Lisp_Object object)
5638 unsigned char *volatile buf;
5639 volatile int len;
5640 volatile Lisp_Object object;
5641{ 5407{
5642 /* Use volatile to protect variables from being clobbered by longjmp. */ 5408 /* Use volatile to protect variables from being clobbered by longjmp. */
5643 struct Lisp_Process *p = XPROCESS (proc); 5409 struct Lisp_Process *p = XPROCESS (proc);
5644 int rv; 5410 int rv;
5645 struct coding_system *coding; 5411 struct coding_system *coding;
5646 struct gcpro gcpro1; 5412 struct gcpro gcpro1;
5647 SIGTYPE (*volatile old_sigpipe) (); 5413 SIGTYPE (*volatile old_sigpipe) (int);
5648 5414
5649 GCPRO1 (object); 5415 GCPRO1 (object);
5650 5416
@@ -5757,7 +5523,7 @@ send_process (proc, buf, len, object)
5757 while (this > 0) 5523 while (this > 0)
5758 { 5524 {
5759 int outfd = p->outfd; 5525 int outfd = p->outfd;
5760 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); 5526 old_sigpipe = (SIGTYPE (*) (int)) signal (SIGPIPE, send_process_trap);
5761#ifdef DATAGRAM_SOCKETS 5527#ifdef DATAGRAM_SOCKETS
5762 if (DATAGRAM_CHAN_P (outfd)) 5528 if (DATAGRAM_CHAN_P (outfd))
5763 { 5529 {
@@ -5882,8 +5648,7 @@ Called from program, takes three arguments, PROCESS, START and END.
5882If the region is more than 500 characters long, 5648If the region is more than 500 characters long,
5883it is sent in several bunches. This may happen even for shorter regions. 5649it is sent in several bunches. This may happen even for shorter regions.
5884Output from processes can arrive in between bunches. */) 5650Output from processes can arrive in between bunches. */)
5885 (process, start, end) 5651 (Lisp_Object process, Lisp_Object start, Lisp_Object end)
5886 Lisp_Object process, start, end;
5887{ 5652{
5888 Lisp_Object proc; 5653 Lisp_Object proc;
5889 int start1, end1; 5654 int start1, end1;
@@ -5910,8 +5675,7 @@ nil, indicating the current buffer's process.
5910If STRING is more than 500 characters long, 5675If STRING is more than 500 characters long,
5911it is sent in several bunches. This may happen even for shorter strings. 5676it is sent in several bunches. This may happen even for shorter strings.
5912Output from processes can arrive in between bunches. */) 5677Output from processes can arrive in between bunches. */)
5913 (process, string) 5678 (Lisp_Object process, Lisp_Object string)
5914 Lisp_Object process, string;
5915{ 5679{
5916 Lisp_Object proc; 5680 Lisp_Object proc;
5917 CHECK_STRING (string); 5681 CHECK_STRING (string);
@@ -5924,8 +5688,7 @@ Output from processes can arrive in between bunches. */)
5924/* Return the foreground process group for the tty/pty that 5688/* Return the foreground process group for the tty/pty that
5925 the process P uses. */ 5689 the process P uses. */
5926static int 5690static int
5927emacs_get_tty_pgrp (p) 5691emacs_get_tty_pgrp (struct Lisp_Process *p)
5928 struct Lisp_Process *p;
5929{ 5692{
5930 int gid = -1; 5693 int gid = -1;
5931 5694
@@ -5953,8 +5716,7 @@ DEFUN ("process-running-child-p", Fprocess_running_child_p,
5953 doc: /* Return t if PROCESS has given the terminal to a child. 5716 doc: /* Return t if PROCESS has given the terminal to a child.
5954If the operating system does not make it possible to find out, 5717If the operating system does not make it possible to find out,
5955return t unconditionally. */) 5718return t unconditionally. */)
5956 (process) 5719 (Lisp_Object process)
5957 Lisp_Object process;
5958{ 5720{
5959 /* Initialize in case ioctl doesn't exist or gives an error, 5721 /* Initialize in case ioctl doesn't exist or gives an error,
5960 in a way that will cause returning t. */ 5722 in a way that will cause returning t. */
@@ -5994,11 +5756,8 @@ return t unconditionally. */)
5994 their uid, for which killpg would return an EPERM error. */ 5756 their uid, for which killpg would return an EPERM error. */
5995 5757
5996static void 5758static void
5997process_send_signal (process, signo, current_group, nomsg) 5759process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
5998 Lisp_Object process; 5760 int nomsg)
5999 int signo;
6000 Lisp_Object current_group;
6001 int nomsg;
6002{ 5761{
6003 Lisp_Object proc; 5762 Lisp_Object proc;
6004 register struct Lisp_Process *p; 5763 register struct Lisp_Process *p;
@@ -6028,9 +5787,6 @@ process_send_signal (process, signo, current_group, nomsg)
6028 /* If possible, send signals to the entire pgrp 5787 /* If possible, send signals to the entire pgrp
6029 by sending an input character to it. */ 5788 by sending an input character to it. */
6030 5789
6031 /* TERMIOS is the latest and bestest, and seems most likely to
6032 work. If the system has it, use it. */
6033#ifdef HAVE_TERMIOS
6034 struct termios t; 5790 struct termios t;
6035 cc_t *sig_char = NULL; 5791 cc_t *sig_char = NULL;
6036 5792
@@ -6062,65 +5818,6 @@ process_send_signal (process, signo, current_group, nomsg)
6062 } 5818 }
6063 /* If we can't send the signal with a character, 5819 /* If we can't send the signal with a character,
6064 fall through and send it another way. */ 5820 fall through and send it another way. */
6065#else /* ! HAVE_TERMIOS */
6066
6067 /* On Berkeley descendants, the following IOCTL's retrieve the
6068 current control characters. */
6069#if defined (TIOCGLTC) && defined (TIOCGETC)
6070
6071 struct tchars c;
6072 struct ltchars lc;
6073
6074 switch (signo)
6075 {
6076 case SIGINT:
6077 ioctl (p->infd, TIOCGETC, &c);
6078 send_process (proc, &c.t_intrc, 1, Qnil);
6079 return;
6080 case SIGQUIT:
6081 ioctl (p->infd, TIOCGETC, &c);
6082 send_process (proc, &c.t_quitc, 1, Qnil);
6083 return;
6084#ifdef SIGTSTP
6085 case SIGTSTP:
6086 ioctl (p->infd, TIOCGLTC, &lc);
6087 send_process (proc, &lc.t_suspc, 1, Qnil);
6088 return;
6089#endif /* ! defined (SIGTSTP) */
6090 }
6091
6092#else /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
6093
6094 /* On SYSV descendants, the TCGETA ioctl retrieves the current control
6095 characters. */
6096#ifdef TCGETA
6097 struct termio t;
6098 switch (signo)
6099 {
6100 case SIGINT:
6101 ioctl (p->infd, TCGETA, &t);
6102 send_process (proc, &t.c_cc[VINTR], 1, Qnil);
6103 return;
6104 case SIGQUIT:
6105 ioctl (p->infd, TCGETA, &t);
6106 send_process (proc, &t.c_cc[VQUIT], 1, Qnil);
6107 return;
6108#ifdef SIGTSTP
6109 case SIGTSTP:
6110 ioctl (p->infd, TCGETA, &t);
6111 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil);
6112 return;
6113#endif /* ! defined (SIGTSTP) */
6114 }
6115#else /* ! defined (TCGETA) */
6116 Your configuration files are messed up.
6117 /* If your system configuration files define SIGNALS_VIA_CHARACTERS,
6118 you'd better be using one of the alternatives above! */
6119#endif /* ! defined (TCGETA) */
6120#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
6121 /* In this case, the code above should alway return. */
6122 abort ();
6123#endif /* ! defined HAVE_TERMIOS */
6124 5821
6125 /* The code above may fall through if it can't 5822 /* The code above may fall through if it can't
6126 handle the signal. */ 5823 handle the signal. */
@@ -6218,8 +5915,7 @@ rather than the shell.
6218 5915
6219If CURRENT-GROUP is `lambda', and if the shell owns the terminal, 5916If CURRENT-GROUP is `lambda', and if the shell owns the terminal,
6220don't send the signal. */) 5917don't send the signal. */)
6221 (process, current_group) 5918 (Lisp_Object process, Lisp_Object current_group)
6222 Lisp_Object process, current_group;
6223{ 5919{
6224 process_send_signal (process, SIGINT, current_group, 0); 5920 process_send_signal (process, SIGINT, current_group, 0);
6225 return process; 5921 return process;
@@ -6228,8 +5924,7 @@ don't send the signal. */)
6228DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, 5924DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0,
6229 doc: /* Kill process PROCESS. May be process or name of one. 5925 doc: /* Kill process PROCESS. May be process or name of one.
6230See function `interrupt-process' for more details on usage. */) 5926See function `interrupt-process' for more details on usage. */)
6231 (process, current_group) 5927 (Lisp_Object process, Lisp_Object current_group)
6232 Lisp_Object process, current_group;
6233{ 5928{
6234 process_send_signal (process, SIGKILL, current_group, 0); 5929 process_send_signal (process, SIGKILL, current_group, 0);
6235 return process; 5930 return process;
@@ -6238,8 +5933,7 @@ See function `interrupt-process' for more details on usage. */)
6238DEFUN ("quit-process", Fquit_process, Squit_process, 0, 2, 0, 5933DEFUN ("quit-process", Fquit_process, Squit_process, 0, 2, 0,
6239 doc: /* Send QUIT signal to process PROCESS. May be process or name of one. 5934 doc: /* Send QUIT signal to process PROCESS. May be process or name of one.
6240See function `interrupt-process' for more details on usage. */) 5935See function `interrupt-process' for more details on usage. */)
6241 (process, current_group) 5936 (Lisp_Object process, Lisp_Object current_group)
6242 Lisp_Object process, current_group;
6243{ 5937{
6244 process_send_signal (process, SIGQUIT, current_group, 0); 5938 process_send_signal (process, SIGQUIT, current_group, 0);
6245 return process; 5939 return process;
@@ -6250,10 +5944,8 @@ DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0,
6250See function `interrupt-process' for more details on usage. 5944See function `interrupt-process' for more details on usage.
6251If PROCESS is a network or serial process, inhibit handling of incoming 5945If PROCESS is a network or serial process, inhibit handling of incoming
6252traffic. */) 5946traffic. */)
6253 (process, current_group) 5947 (Lisp_Object process, Lisp_Object current_group)
6254 Lisp_Object process, current_group;
6255{ 5948{
6256#ifdef HAVE_SOCKETS
6257 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) 5949 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
6258 { 5950 {
6259 struct Lisp_Process *p; 5951 struct Lisp_Process *p;
@@ -6268,7 +5960,6 @@ traffic. */)
6268 p->command = Qt; 5960 p->command = Qt;
6269 return process; 5961 return process;
6270 } 5962 }
6271#endif
6272#ifndef SIGTSTP 5963#ifndef SIGTSTP
6273 error ("No SIGTSTP support"); 5964 error ("No SIGTSTP support");
6274#else 5965#else
@@ -6282,10 +5973,8 @@ DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0,
6282See function `interrupt-process' for more details on usage. 5973See function `interrupt-process' for more details on usage.
6283If PROCESS is a network or serial process, resume handling of incoming 5974If PROCESS is a network or serial process, resume handling of incoming
6284traffic. */) 5975traffic. */)
6285 (process, current_group) 5976 (Lisp_Object process, Lisp_Object current_group)
6286 Lisp_Object process, current_group;
6287{ 5977{
6288#ifdef HAVE_SOCKETS
6289 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) 5978 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process)))
6290 { 5979 {
6291 struct Lisp_Process *p; 5980 struct Lisp_Process *p;
@@ -6300,15 +5989,13 @@ traffic. */)
6300#ifdef WINDOWSNT 5989#ifdef WINDOWSNT
6301 if (fd_info[ p->infd ].flags & FILE_SERIAL) 5990 if (fd_info[ p->infd ].flags & FILE_SERIAL)
6302 PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR); 5991 PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR);
6303#endif 5992#else /* not WINDOWSNT */
6304#ifdef HAVE_TERMIOS
6305 tcflush (p->infd, TCIFLUSH); 5993 tcflush (p->infd, TCIFLUSH);
6306#endif 5994#endif /* not WINDOWSNT */
6307 } 5995 }
6308 p->command = Qnil; 5996 p->command = Qnil;
6309 return process; 5997 return process;
6310 } 5998 }
6311#endif
6312#ifdef SIGCONT 5999#ifdef SIGCONT
6313 process_send_signal (process, SIGCONT, current_group, 0); 6000 process_send_signal (process, SIGCONT, current_group, 0);
6314#else 6001#else
@@ -6324,8 +6011,7 @@ PROCESS may also be a number specifying the process id of the
6324process to signal; in this case, the process need not be a child of 6011process to signal; in this case, the process need not be a child of
6325this Emacs. 6012this Emacs.
6326SIGCODE may be an integer, or a symbol whose name is a signal name. */) 6013SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6327 (process, sigcode) 6014 (Lisp_Object process, Lisp_Object sigcode)
6328 Lisp_Object process, sigcode;
6329{ 6015{
6330 pid_t pid; 6016 pid_t pid;
6331 6017
@@ -6378,7 +6064,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6378 CHECK_SYMBOL (sigcode); 6064 CHECK_SYMBOL (sigcode);
6379 name = SDATA (SYMBOL_NAME (sigcode)); 6065 name = SDATA (SYMBOL_NAME (sigcode));
6380 6066
6381 if (!strncmp(name, "SIG", 3) || !strncmp(name, "sig", 3)) 6067 if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
6382 name += 3; 6068 name += 3;
6383 6069
6384 if (0) 6070 if (0)
@@ -6492,8 +6178,7 @@ through a pipe (as opposed to a pty), then you cannot send any more
6492text to PROCESS after you call this function. 6178text to PROCESS after you call this function.
6493If PROCESS is a serial process, wait until all output written to the 6179If PROCESS is a serial process, wait until all output written to the
6494process has been transmitted to the serial port. */) 6180process has been transmitted to the serial port. */)
6495 (process) 6181 (Lisp_Object process)
6496 Lisp_Object process;
6497{ 6182{
6498 Lisp_Object proc; 6183 Lisp_Object proc;
6499 struct coding_system *coding; 6184 struct coding_system *coding;
@@ -6520,10 +6205,10 @@ process has been transmitted to the serial port. */)
6520 send_process (proc, "\004", 1, Qnil); 6205 send_process (proc, "\004", 1, Qnil);
6521 else if (EQ (XPROCESS (proc)->type, Qserial)) 6206 else if (EQ (XPROCESS (proc)->type, Qserial))
6522 { 6207 {
6523#ifdef HAVE_TERMIOS 6208#ifndef WINDOWSNT
6524 if (tcdrain (XPROCESS (proc)->outfd) != 0) 6209 if (tcdrain (XPROCESS (proc)->outfd) != 0)
6525 error ("tcdrain() failed: %s", emacs_strerror (errno)); 6210 error ("tcdrain() failed: %s", emacs_strerror (errno));
6526#endif 6211#endif /* not WINDOWSNT */
6527 /* Do nothing on Windows because writes are blocking. */ 6212 /* Do nothing on Windows because writes are blocking. */
6528 } 6213 }
6529 else 6214 else
@@ -6552,39 +6237,16 @@ process has been transmitted to the serial port. */)
6552 if (!proc_encode_coding_system[new_outfd]) 6237 if (!proc_encode_coding_system[new_outfd])
6553 proc_encode_coding_system[new_outfd] 6238 proc_encode_coding_system[new_outfd]
6554 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); 6239 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
6555 bcopy (proc_encode_coding_system[old_outfd], 6240 memcpy (proc_encode_coding_system[new_outfd],
6556 proc_encode_coding_system[new_outfd], 6241 proc_encode_coding_system[old_outfd],
6557 sizeof (struct coding_system)); 6242 sizeof (struct coding_system));
6558 bzero (proc_encode_coding_system[old_outfd], 6243 memset (proc_encode_coding_system[old_outfd], 0,
6559 sizeof (struct coding_system)); 6244 sizeof (struct coding_system));
6560 6245
6561 XPROCESS (proc)->outfd = new_outfd; 6246 XPROCESS (proc)->outfd = new_outfd;
6562 } 6247 }
6563 return process; 6248 return process;
6564} 6249}
6565
6566/* Kill all processes associated with `buffer'.
6567 If `buffer' is nil, kill all processes */
6568
6569void
6570kill_buffer_processes (buffer)
6571 Lisp_Object buffer;
6572{
6573 Lisp_Object tail, proc;
6574
6575 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
6576 {
6577 proc = XCDR (XCAR (tail));
6578 if (PROCESSP (proc)
6579 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)))
6580 {
6581 if (NETCONN_P (proc) || SERIALCONN_P (proc))
6582 Fdelete_process (proc);
6583 else if (XPROCESS (proc)->infd >= 0)
6584 process_send_signal (proc, SIGHUP, Qnil, 1);
6585 }
6586 }
6587}
6588 6250
6589/* On receipt of a signal that a child status has changed, loop asking 6251/* On receipt of a signal that a child status has changed, loop asking
6590 about children with changed statuses until the system says there 6252 about children with changed statuses until the system says there
@@ -6613,13 +6275,11 @@ kill_buffer_processes (buffer)
6613 6275
6614#ifdef SIGCHLD 6276#ifdef SIGCHLD
6615SIGTYPE 6277SIGTYPE
6616sigchld_handler (signo) 6278sigchld_handler (int signo)
6617 int signo;
6618{ 6279{
6619 int old_errno = errno; 6280 int old_errno = errno;
6620 Lisp_Object proc; 6281 Lisp_Object proc;
6621 register struct Lisp_Process *p; 6282 struct Lisp_Process *p;
6622 extern EMACS_TIME *input_available_clear_time;
6623 6283
6624 SIGNAL_THREAD_CHECK (signo); 6284 SIGNAL_THREAD_CHECK (signo);
6625 6285
@@ -6755,16 +6415,14 @@ sigchld_handler (signo)
6755 6415
6756 6416
6757static Lisp_Object 6417static Lisp_Object
6758exec_sentinel_unwind (data) 6418exec_sentinel_unwind (Lisp_Object data)
6759 Lisp_Object data;
6760{ 6419{
6761 XPROCESS (XCAR (data))->sentinel = XCDR (data); 6420 XPROCESS (XCAR (data))->sentinel = XCDR (data);
6762 return Qnil; 6421 return Qnil;
6763} 6422}
6764 6423
6765static Lisp_Object 6424static Lisp_Object
6766exec_sentinel_error_handler (error) 6425exec_sentinel_error_handler (Lisp_Object error)
6767 Lisp_Object error;
6768{ 6426{
6769 cmd_error_internal (error, "error in process sentinel: "); 6427 cmd_error_internal (error, "error in process sentinel: ");
6770 Vinhibit_quit = Qt; 6428 Vinhibit_quit = Qt;
@@ -6774,8 +6432,7 @@ exec_sentinel_error_handler (error)
6774} 6432}
6775 6433
6776static void 6434static void
6777exec_sentinel (proc, reason) 6435exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6778 Lisp_Object proc, reason;
6779{ 6436{
6780 Lisp_Object sentinel, obuffer, odeactivate, okeymap; 6437 Lisp_Object sentinel, obuffer, odeactivate, okeymap;
6781 register struct Lisp_Process *p = XPROCESS (proc); 6438 register struct Lisp_Process *p = XPROCESS (proc);
@@ -6860,8 +6517,7 @@ exec_sentinel (proc, reason)
6860 but can be done at other times. */ 6517 but can be done at other times. */
6861 6518
6862static void 6519static void
6863status_notify (deleting_process) 6520status_notify (struct Lisp_Process *deleting_process)
6864 struct Lisp_Process *deleting_process;
6865{ 6521{
6866 register Lisp_Object proc, buffer; 6522 register Lisp_Object proc, buffer;
6867 Lisp_Object tail, msg; 6523 Lisp_Object tail, msg;
@@ -6988,8 +6644,7 @@ DEFUN ("set-process-coding-system", Fset_process_coding_system,
6988 doc: /* Set coding systems of PROCESS to DECODING and ENCODING. 6644 doc: /* Set coding systems of PROCESS to DECODING and ENCODING.
6989DECODING will be used to decode subprocess output and ENCODING to 6645DECODING will be used to decode subprocess output and ENCODING to
6990encode subprocess input. */) 6646encode subprocess input. */)
6991 (process, decoding, encoding) 6647 (register Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding)
6992 register Lisp_Object process, decoding, encoding;
6993{ 6648{
6994 register struct Lisp_Process *p; 6649 register struct Lisp_Process *p;
6995 6650
@@ -7012,8 +6667,7 @@ encode subprocess input. */)
7012DEFUN ("process-coding-system", 6667DEFUN ("process-coding-system",
7013 Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0, 6668 Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0,
7014 doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */) 6669 doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */)
7015 (process) 6670 (register Lisp_Object process)
7016 register Lisp_Object process;
7017{ 6671{
7018 CHECK_PROCESS (process); 6672 CHECK_PROCESS (process);
7019 return Fcons (XPROCESS (process)->decode_coding_system, 6673 return Fcons (XPROCESS (process)->decode_coding_system,
@@ -7027,8 +6681,7 @@ If FLAG is non-nil, the filter is given multibyte strings.
7027If FLAG is nil, the filter is given unibyte strings. In this case, 6681If FLAG is nil, the filter is given unibyte strings. In this case,
7028all character code conversion except for end-of-line conversion is 6682all character code conversion except for end-of-line conversion is
7029suppressed. */) 6683suppressed. */)
7030 (process, flag) 6684 (Lisp_Object process, Lisp_Object flag)
7031 Lisp_Object process, flag;
7032{ 6685{
7033 register struct Lisp_Process *p; 6686 register struct Lisp_Process *p;
7034 6687
@@ -7044,8 +6697,7 @@ suppressed. */)
7044DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, 6697DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
7045 Sprocess_filter_multibyte_p, 1, 1, 0, 6698 Sprocess_filter_multibyte_p, 1, 1, 0,
7046 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/) 6699 doc: /* Return t if a multibyte string is given to PROCESS's filter.*/)
7047 (process) 6700 (Lisp_Object process)
7048 Lisp_Object process;
7049{ 6701{
7050 register struct Lisp_Process *p; 6702 register struct Lisp_Process *p;
7051 struct coding_system *coding; 6703 struct coding_system *coding;
@@ -7058,23 +6710,11 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
7058 6710
7059 6711
7060 6712
7061/* Add DESC to the set of keyboard input descriptors. */
7062
7063void
7064add_keyboard_wait_descriptor (desc)
7065 int desc;
7066{
7067 FD_SET (desc, &input_wait_mask);
7068 FD_SET (desc, &non_process_wait_mask);
7069 if (desc > max_keyboard_desc)
7070 max_keyboard_desc = desc;
7071}
7072 6713
7073static int add_gpm_wait_descriptor_called_flag; 6714static int add_gpm_wait_descriptor_called_flag;
7074 6715
7075void 6716void
7076add_gpm_wait_descriptor (desc) 6717add_gpm_wait_descriptor (int desc)
7077 int desc;
7078{ 6718{
7079 if (! add_gpm_wait_descriptor_called_flag) 6719 if (! add_gpm_wait_descriptor_called_flag)
7080 FD_CLR (0, &input_wait_mask); 6720 FD_CLR (0, &input_wait_mask);
@@ -7085,29 +6725,8 @@ add_gpm_wait_descriptor (desc)
7085 max_gpm_desc = desc; 6725 max_gpm_desc = desc;
7086} 6726}
7087 6727
7088/* From now on, do not expect DESC to give keyboard input. */
7089
7090void 6728void
7091delete_keyboard_wait_descriptor (desc) 6729delete_gpm_wait_descriptor (int desc)
7092 int desc;
7093{
7094 int fd;
7095 int lim = max_keyboard_desc;
7096
7097 FD_CLR (desc, &input_wait_mask);
7098 FD_CLR (desc, &non_process_wait_mask);
7099
7100 if (desc == max_keyboard_desc)
7101 for (fd = 0; fd < lim; fd++)
7102 if (FD_ISSET (fd, &input_wait_mask)
7103 && !FD_ISSET (fd, &non_keyboard_wait_mask)
7104 && !FD_ISSET (fd, &gpm_wait_mask))
7105 max_keyboard_desc = fd;
7106}
7107
7108void
7109delete_gpm_wait_descriptor (desc)
7110 int desc;
7111{ 6730{
7112 int fd; 6731 int fd;
7113 int lim = max_gpm_desc; 6732 int lim = max_gpm_desc;
@@ -7127,8 +6746,7 @@ delete_gpm_wait_descriptor (desc)
7127 that corresponds to one of the keyboard input descriptors. */ 6746 that corresponds to one of the keyboard input descriptors. */
7128 6747
7129static int 6748static int
7130keyboard_bit_set (mask) 6749keyboard_bit_set (fd_set *mask)
7131 SELECT_TYPE *mask;
7132{ 6750{
7133 int fd; 6751 int fd;
7134 6752
@@ -7139,6 +6757,432 @@ keyboard_bit_set (mask)
7139 6757
7140 return 0; 6758 return 0;
7141} 6759}
6760
6761#else /* not subprocesses */
6762
6763/* Defined on msdos.c. */
6764extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
6765 EMACS_TIME *);
6766
6767/* Implementation of wait_reading_process_output, assuming that there
6768 are no subprocesses. Used only by the MS-DOS build.
6769
6770 Wait for timeout to elapse and/or keyboard input to be available.
6771
6772 time_limit is:
6773 timeout in seconds, or
6774 zero for no limit, or
6775 -1 means gobble data immediately available but don't wait for any.
6776
6777 read_kbd is a Lisp_Object:
6778 0 to ignore keyboard input, or
6779 1 to return when input is available, or
6780 -1 means caller will actually read the input, so don't throw to
6781 the quit handler.
6782
6783 see full version for other parameters. We know that wait_proc will
6784 always be NULL, since `subprocesses' isn't defined.
6785
6786 do_display != 0 means redisplay should be done to show subprocess
6787 output that arrives.
6788
6789 Return true if we received input from any process. */
6790
6791int
6792wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
6793 int do_display,
6794 Lisp_Object wait_for_cell,
6795 struct Lisp_Process *wait_proc, int just_wait_proc)
6796{
6797 register int nfds;
6798 EMACS_TIME end_time, timeout;
6799 SELECT_TYPE waitchannels;
6800 int xerrno;
6801
6802 /* What does time_limit really mean? */
6803 if (time_limit || microsecs)
6804 {
6805 EMACS_GET_TIME (end_time);
6806 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs);
6807 EMACS_ADD_TIME (end_time, end_time, timeout);
6808 }
6809
6810 /* Turn off periodic alarms (in case they are in use)
6811 and then turn off any other atimers,
6812 because the select emulator uses alarms. */
6813 stop_polling ();
6814 turn_on_atimers (0);
6815
6816 while (1)
6817 {
6818 int timeout_reduced_for_timers = 0;
6819
6820 /* If calling from keyboard input, do not quit
6821 since we want to return C-g as an input character.
6822 Otherwise, do pending quit if requested. */
6823 if (read_kbd >= 0)
6824 QUIT;
6825
6826 /* Exit now if the cell we're waiting for became non-nil. */
6827 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
6828 break;
6829
6830 /* Compute time from now till when time limit is up */
6831 /* Exit if already run out */
6832 if (time_limit == -1)
6833 {
6834 /* -1 specified for timeout means
6835 gobble output available now
6836 but don't wait at all. */
6837
6838 EMACS_SET_SECS_USECS (timeout, 0, 0);
6839 }
6840 else if (time_limit || microsecs)
6841 {
6842 EMACS_GET_TIME (timeout);
6843 EMACS_SUB_TIME (timeout, end_time, timeout);
6844 if (EMACS_TIME_NEG_P (timeout))
6845 break;
6846 }
6847 else
6848 {
6849 EMACS_SET_SECS_USECS (timeout, 100000, 0);
6850 }
6851
6852 /* If our caller will not immediately handle keyboard events,
6853 run timer events directly.
6854 (Callers that will immediately read keyboard events
6855 call timer_delay on their own.) */
6856 if (NILP (wait_for_cell))
6857 {
6858 EMACS_TIME timer_delay;
6859
6860 do
6861 {
6862 int old_timers_run = timers_run;
6863 timer_delay = timer_check (1);
6864 if (timers_run != old_timers_run && do_display)
6865 /* We must retry, since a timer may have requeued itself
6866 and that could alter the time delay. */
6867 redisplay_preserve_echo_area (14);
6868 else
6869 break;
6870 }
6871 while (!detect_input_pending ());
6872
6873 /* If there is unread keyboard input, also return. */
6874 if (read_kbd != 0
6875 && requeued_events_pending_p ())
6876 break;
6877
6878 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1)
6879 {
6880 EMACS_TIME difference;
6881 EMACS_SUB_TIME (difference, timer_delay, timeout);
6882 if (EMACS_TIME_NEG_P (difference))
6883 {
6884 timeout = timer_delay;
6885 timeout_reduced_for_timers = 1;
6886 }
6887 }
6888 }
6889
6890 /* Cause C-g and alarm signals to take immediate action,
6891 and cause input available signals to zero out timeout. */
6892 if (read_kbd < 0)
6893 set_waiting_for_input (&timeout);
6894
6895 /* Wait till there is something to do. */
6896
6897 if (! read_kbd && NILP (wait_for_cell))
6898 FD_ZERO (&waitchannels);
6899 else
6900 FD_SET (0, &waitchannels);
6901
6902 /* If a frame has been newly mapped and needs updating,
6903 reprocess its display stuff. */
6904 if (frame_garbaged && do_display)
6905 {
6906 clear_waiting_for_input ();
6907 redisplay_preserve_echo_area (15);
6908 if (read_kbd < 0)
6909 set_waiting_for_input (&timeout);
6910 }
6911
6912 if (read_kbd && detect_input_pending ())
6913 {
6914 nfds = 0;
6915 FD_ZERO (&waitchannels);
6916 }
6917 else
6918 nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0,
6919 &timeout);
6920
6921 xerrno = errno;
6922
6923 /* Make C-g and alarm signals set flags again */
6924 clear_waiting_for_input ();
6925
6926 /* If we woke up due to SIGWINCH, actually change size now. */
6927 do_pending_window_change (0);
6928
6929 if (time_limit && nfds == 0 && ! timeout_reduced_for_timers)
6930 /* We waited the full specified time, so return now. */
6931 break;
6932
6933 if (nfds == -1)
6934 {
6935 /* If the system call was interrupted, then go around the
6936 loop again. */
6937 if (xerrno == EINTR)
6938 FD_ZERO (&waitchannels);
6939 else
6940 error ("select error: %s", emacs_strerror (xerrno));
6941 }
6942
6943 /* Check for keyboard input */
6944
6945 if (read_kbd
6946 && detect_input_pending_run_timers (do_display))
6947 {
6948 swallow_events (do_display);
6949 if (detect_input_pending_run_timers (do_display))
6950 break;
6951 }
6952
6953 /* If there is unread keyboard input, also return. */
6954 if (read_kbd
6955 && requeued_events_pending_p ())
6956 break;
6957
6958 /* If wait_for_cell. check for keyboard input
6959 but don't run any timers.
6960 ??? (It seems wrong to me to check for keyboard
6961 input at all when wait_for_cell, but the code
6962 has been this way since July 1994.
6963 Try changing this after version 19.31.) */
6964 if (! NILP (wait_for_cell)
6965 && detect_input_pending ())
6966 {
6967 swallow_events (do_display);
6968 if (detect_input_pending ())
6969 break;
6970 }
6971
6972 /* Exit now if the cell we're waiting for became non-nil. */
6973 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
6974 break;
6975 }
6976
6977 start_polling ();
6978
6979 return 0;
6980}
6981
6982#endif /* not subprocesses */
6983
6984/* The following functions are needed even if async subprocesses are
6985 not supported. Some of them are no-op stubs in that case. */
6986
6987/* Add DESC to the set of keyboard input descriptors. */
6988
6989void
6990add_keyboard_wait_descriptor (int desc)
6991{
6992#ifdef subprocesses
6993 FD_SET (desc, &input_wait_mask);
6994 FD_SET (desc, &non_process_wait_mask);
6995 if (desc > max_keyboard_desc)
6996 max_keyboard_desc = desc;
6997#endif
6998}
6999
7000/* From now on, do not expect DESC to give keyboard input. */
7001
7002void
7003delete_keyboard_wait_descriptor (int desc)
7004{
7005#ifdef subprocesses
7006 int fd;
7007 int lim = max_keyboard_desc;
7008
7009 FD_CLR (desc, &input_wait_mask);
7010 FD_CLR (desc, &non_process_wait_mask);
7011
7012 if (desc == max_keyboard_desc)
7013 for (fd = 0; fd < lim; fd++)
7014 if (FD_ISSET (fd, &input_wait_mask)
7015 && !FD_ISSET (fd, &non_keyboard_wait_mask)
7016 && !FD_ISSET (fd, &gpm_wait_mask))
7017 max_keyboard_desc = fd;
7018#endif /* subprocesses */
7019}
7020
7021/* Setup coding systems of PROCESS. */
7022
7023void
7024setup_process_coding_systems (Lisp_Object process)
7025{
7026#ifdef subprocesses
7027 struct Lisp_Process *p = XPROCESS (process);
7028 int inch = p->infd;
7029 int outch = p->outfd;
7030 Lisp_Object coding_system;
7031
7032 if (inch < 0 || outch < 0)
7033 return;
7034
7035 if (!proc_decode_coding_system[inch])
7036 proc_decode_coding_system[inch]
7037 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
7038 coding_system = p->decode_coding_system;
7039 if (! NILP (p->filter))
7040 ;
7041 else if (BUFFERP (p->buffer))
7042 {
7043 if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
7044 coding_system = raw_text_coding_system (coding_system);
7045 }
7046 setup_coding_system (coding_system, proc_decode_coding_system[inch]);
7047
7048 if (!proc_encode_coding_system[outch])
7049 proc_encode_coding_system[outch]
7050 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
7051 setup_coding_system (p->encode_coding_system,
7052 proc_encode_coding_system[outch]);
7053#endif
7054}
7055
7056/* Close all descriptors currently in use for communication
7057 with subprocess. This is used in a newly-forked subprocess
7058 to get rid of irrelevant descriptors. */
7059
7060void
7061close_process_descs (void)
7062{
7063#ifndef DOS_NT
7064 int i;
7065 for (i = 0; i < MAXDESC; i++)
7066 {
7067 Lisp_Object process;
7068 process = chan_process[i];
7069 if (!NILP (process))
7070 {
7071 int in = XPROCESS (process)->infd;
7072 int out = XPROCESS (process)->outfd;
7073 if (in >= 0)
7074 emacs_close (in);
7075 if (out >= 0 && in != out)
7076 emacs_close (out);
7077 }
7078 }
7079#endif
7080}
7081
7082DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
7083 doc: /* Return the (or a) process associated with BUFFER.
7084BUFFER may be a buffer or the name of one. */)
7085 (register Lisp_Object buffer)
7086{
7087#ifdef subprocesses
7088 register Lisp_Object buf, tail, proc;
7089
7090 if (NILP (buffer)) return Qnil;
7091 buf = Fget_buffer (buffer);
7092 if (NILP (buf)) return Qnil;
7093
7094 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
7095 {
7096 proc = Fcdr (XCAR (tail));
7097 if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
7098 return proc;
7099 }
7100#endif /* subprocesses */
7101 return Qnil;
7102}
7103
7104DEFUN ("process-inherit-coding-system-flag",
7105 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
7106 1, 1, 0,
7107 doc: /* Return the value of inherit-coding-system flag for PROCESS.
7108If this flag is t, `buffer-file-coding-system' of the buffer
7109associated with PROCESS will inherit the coding system used to decode
7110the process output. */)
7111 (register Lisp_Object process)
7112{
7113#ifdef subprocesses
7114 CHECK_PROCESS (process);
7115 return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil;
7116#else
7117 /* Ignore the argument and return the value of
7118 inherit-process-coding-system. */
7119 return inherit_process_coding_system ? Qt : Qnil;
7120#endif
7121}
7122
7123/* Kill all processes associated with `buffer'.
7124 If `buffer' is nil, kill all processes */
7125
7126void
7127kill_buffer_processes (Lisp_Object buffer)
7128{
7129#ifdef subprocesses
7130 Lisp_Object tail, proc;
7131
7132 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail))
7133 {
7134 proc = XCDR (XCAR (tail));
7135 if (PROCESSP (proc)
7136 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)))
7137 {
7138 if (NETCONN_P (proc) || SERIALCONN_P (proc))
7139 Fdelete_process (proc);
7140 else if (XPROCESS (proc)->infd >= 0)
7141 process_send_signal (proc, SIGHUP, Qnil, 1);
7142 }
7143 }
7144#else /* subprocesses */
7145 /* Since we have no subprocesses, this does nothing. */
7146#endif /* subprocesses */
7147}
7148
7149DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p,
7150 0, 0, 0,
7151 doc: /* Returns non-nil if Emacs is waiting for input from the user.
7152This is intended for use by asynchronous process output filters and sentinels. */)
7153 (void)
7154{
7155#ifdef subprocesses
7156 return (waiting_for_user_input_p ? Qt : Qnil);
7157#else
7158 return Qnil;
7159#endif
7160}
7161
7162/* Stop reading input from keyboard sources. */
7163
7164void
7165hold_keyboard_input (void)
7166{
7167 kbd_is_on_hold = 1;
7168}
7169
7170/* Resume reading input from keyboard sources. */
7171
7172void
7173unhold_keyboard_input (void)
7174{
7175 kbd_is_on_hold = 0;
7176}
7177
7178/* Return non-zero if keyboard input is on hold, zero otherwise. */
7179
7180int
7181kbd_on_hold_p (void)
7182{
7183 return kbd_is_on_hold;
7184}
7185
7142 7186
7143/* Enumeration of and access to system processes a-la ps(1). */ 7187/* Enumeration of and access to system processes a-la ps(1). */
7144 7188
@@ -7148,7 +7192,7 @@ DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes,
7148If this functionality is unsupported, return nil. 7192If this functionality is unsupported, return nil.
7149 7193
7150See `process-attributes' for getting attributes of a process given its ID. */) 7194See `process-attributes' for getting attributes of a process given its ID. */)
7151 () 7195 (void)
7152{ 7196{
7153 return list_system_processes (); 7197 return list_system_processes ();
7154} 7198}
@@ -7204,16 +7248,16 @@ integer or floating point values.
7204 pmem -- percents of total physical memory used by process's resident set 7248 pmem -- percents of total physical memory used by process's resident set
7205 (floating-point number) 7249 (floating-point number)
7206 args -- command line which invoked the process (string). */) 7250 args -- command line which invoked the process (string). */)
7207 (pid) 7251 ( Lisp_Object pid)
7208
7209 Lisp_Object pid;
7210{ 7252{
7211 return system_process_attributes (pid); 7253 return system_process_attributes (pid);
7212} 7254}
7255
7213 7256
7214void 7257void
7215init_process () 7258init_process (void)
7216{ 7259{
7260#ifdef subprocesses
7217 register int i; 7261 register int i;
7218 7262
7219 inhibit_sentinels = 0; 7263 inhibit_sentinels = 0;
@@ -7256,13 +7300,12 @@ init_process ()
7256 chan_process[i] = Qnil; 7300 chan_process[i] = Qnil;
7257 proc_buffered_char[i] = -1; 7301 proc_buffered_char[i] = -1;
7258 } 7302 }
7259 bzero (proc_decode_coding_system, sizeof proc_decode_coding_system); 7303 memset (proc_decode_coding_system, 0, sizeof proc_decode_coding_system);
7260 bzero (proc_encode_coding_system, sizeof proc_encode_coding_system); 7304 memset (proc_encode_coding_system, 0, sizeof proc_encode_coding_system);
7261#ifdef DATAGRAM_SOCKETS 7305#ifdef DATAGRAM_SOCKETS
7262 bzero (datagram_address, sizeof datagram_address); 7306 memset (datagram_address, 0, sizeof datagram_address);
7263#endif 7307#endif
7264 7308
7265#ifdef HAVE_SOCKETS
7266 { 7309 {
7267 Lisp_Object subfeatures = Qnil; 7310 Lisp_Object subfeatures = Qnil;
7268 const struct socket_options *sopt; 7311 const struct socket_options *sopt;
@@ -7298,25 +7341,28 @@ init_process ()
7298 7341
7299 Fprovide (intern_c_string ("make-network-process"), subfeatures); 7342 Fprovide (intern_c_string ("make-network-process"), subfeatures);
7300 } 7343 }
7301#endif /* HAVE_SOCKETS */
7302 7344
7303#if defined (DARWIN_OS) 7345#if defined (DARWIN_OS)
7304 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive 7346 /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
7305 processes. As such, we only change the default value. */ 7347 processes. As such, we only change the default value. */
7306 if (initialized) 7348 if (initialized)
7307 { 7349 {
7308 char *release = get_operating_system_release(); 7350 const char *release = get_operating_system_release ();
7309 if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION 7351 if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION
7310 && release[1] == '.')) { 7352 && release[1] == '.')) {
7311 Vprocess_connection_type = Qnil; 7353 Vprocess_connection_type = Qnil;
7312 } 7354 }
7313 } 7355 }
7314#endif 7356#endif
7357#endif /* subprocesses */
7358 kbd_is_on_hold = 0;
7315} 7359}
7316 7360
7317void 7361void
7318syms_of_process () 7362syms_of_process (void)
7319{ 7363{
7364#ifdef subprocesses
7365
7320 Qprocessp = intern_c_string ("processp"); 7366 Qprocessp = intern_c_string ("processp");
7321 staticpro (&Qprocessp); 7367 staticpro (&Qprocessp);
7322 Qrun = intern_c_string ("run"); 7368 Qrun = intern_c_string ("run");
@@ -7387,17 +7433,12 @@ syms_of_process ()
7387 staticpro (&Qnetwork); 7433 staticpro (&Qnetwork);
7388 Qserial = intern_c_string ("serial"); 7434 Qserial = intern_c_string ("serial");
7389 staticpro (&Qserial); 7435 staticpro (&Qserial);
7390
7391 QCname = intern_c_string (":name");
7392 staticpro (&QCname);
7393 QCbuffer = intern_c_string (":buffer"); 7436 QCbuffer = intern_c_string (":buffer");
7394 staticpro (&QCbuffer); 7437 staticpro (&QCbuffer);
7395 QChost = intern_c_string (":host"); 7438 QChost = intern_c_string (":host");
7396 staticpro (&QChost); 7439 staticpro (&QChost);
7397 QCservice = intern_c_string (":service"); 7440 QCservice = intern_c_string (":service");
7398 staticpro (&QCservice); 7441 staticpro (&QCservice);
7399 QCtype = intern_c_string (":type");
7400 staticpro (&QCtype);
7401 QClocal = intern_c_string (":local"); 7442 QClocal = intern_c_string (":local");
7402 staticpro (&QClocal); 7443 staticpro (&QClocal);
7403 QCremote = intern_c_string (":remote"); 7444 QCremote = intern_c_string (":remote");
@@ -7429,6 +7470,13 @@ syms_of_process ()
7429 staticpro (&deleted_pid_list); 7470 staticpro (&deleted_pid_list);
7430#endif 7471#endif
7431 7472
7473#endif /* subprocesses */
7474
7475 QCname = intern_c_string (":name");
7476 staticpro (&QCname);
7477 QCtype = intern_c_string (":type");
7478 staticpro (&QCtype);
7479
7432 Qeuid = intern_c_string ("euid"); 7480 Qeuid = intern_c_string ("euid");
7433 staticpro (&Qeuid); 7481 staticpro (&Qeuid);
7434 Qegid = intern_c_string ("egid"); 7482 Qegid = intern_c_string ("egid");
@@ -7498,6 +7546,7 @@ A value of nil means don't delete them until `list-processes' is run. */);
7498 7546
7499 delete_exited_processes = 1; 7547 delete_exited_processes = 1;
7500 7548
7549#ifdef subprocesses
7501 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type, 7550 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type,
7502 doc: /* Control type of device used to communicate with subprocesses. 7551 doc: /* Control type of device used to communicate with subprocesses.
7503Values are nil to use a pipe, or t or `pty' to use a pty. 7552Values are nil to use a pipe, or t or `pty' to use a pty.
@@ -7522,7 +7571,6 @@ The variable takes effect when `start-process' is called. */);
7522 7571
7523 defsubr (&Sprocessp); 7572 defsubr (&Sprocessp);
7524 defsubr (&Sget_process); 7573 defsubr (&Sget_process);
7525 defsubr (&Sget_buffer_process);
7526 defsubr (&Sdelete_process); 7574 defsubr (&Sdelete_process);
7527 defsubr (&Sprocess_status); 7575 defsubr (&Sprocess_status);
7528 defsubr (&Sprocess_exit_status); 7576 defsubr (&Sprocess_exit_status);
@@ -7539,7 +7587,6 @@ The variable takes effect when `start-process' is called. */);
7539 defsubr (&Sprocess_sentinel); 7587 defsubr (&Sprocess_sentinel);
7540 defsubr (&Sset_process_window_size); 7588 defsubr (&Sset_process_window_size);
7541 defsubr (&Sset_process_inherit_coding_system_flag); 7589 defsubr (&Sset_process_inherit_coding_system_flag);
7542 defsubr (&Sprocess_inherit_coding_system_flag);
7543 defsubr (&Sset_process_query_on_exit_flag); 7590 defsubr (&Sset_process_query_on_exit_flag);
7544 defsubr (&Sprocess_query_on_exit_flag); 7591 defsubr (&Sprocess_query_on_exit_flag);
7545 defsubr (&Sprocess_contact); 7592 defsubr (&Sprocess_contact);
@@ -7548,23 +7595,19 @@ The variable takes effect when `start-process' is called. */);
7548 defsubr (&Slist_processes); 7595 defsubr (&Slist_processes);
7549 defsubr (&Sprocess_list); 7596 defsubr (&Sprocess_list);
7550 defsubr (&Sstart_process); 7597 defsubr (&Sstart_process);
7551#ifdef HAVE_SERIAL
7552 defsubr (&Sserial_process_configure); 7598 defsubr (&Sserial_process_configure);
7553 defsubr (&Smake_serial_process); 7599 defsubr (&Smake_serial_process);
7554#endif /* HAVE_SERIAL */
7555#ifdef HAVE_SOCKETS
7556 defsubr (&Sset_network_process_option); 7600 defsubr (&Sset_network_process_option);
7557 defsubr (&Smake_network_process); 7601 defsubr (&Smake_network_process);
7558 defsubr (&Sformat_network_address); 7602 defsubr (&Sformat_network_address);
7559#endif /* HAVE_SOCKETS */ 7603#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
7560#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H)
7561#ifdef SIOCGIFCONF 7604#ifdef SIOCGIFCONF
7562 defsubr (&Snetwork_interface_list); 7605 defsubr (&Snetwork_interface_list);
7563#endif 7606#endif
7564#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) 7607#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
7565 defsubr (&Snetwork_interface_info); 7608 defsubr (&Snetwork_interface_info);
7566#endif 7609#endif
7567#endif /* HAVE_SOCKETS ... */ 7610#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */
7568#ifdef DATAGRAM_SOCKETS 7611#ifdef DATAGRAM_SOCKETS
7569 defsubr (&Sprocess_datagram_address); 7612 defsubr (&Sprocess_datagram_address);
7570 defsubr (&Sset_process_datagram_address); 7613 defsubr (&Sset_process_datagram_address);
@@ -7586,449 +7629,8 @@ The variable takes effect when `start-process' is called. */);
7586 defsubr (&Sprocess_coding_system); 7629 defsubr (&Sprocess_coding_system);
7587 defsubr (&Sset_process_filter_multibyte); 7630 defsubr (&Sset_process_filter_multibyte);
7588 defsubr (&Sprocess_filter_multibyte_p); 7631 defsubr (&Sprocess_filter_multibyte_p);
7589 defsubr (&Slist_system_processes);
7590 defsubr (&Sprocess_attributes);
7591}
7592
7593
7594#else /* not subprocesses */
7595
7596#include <sys/types.h>
7597#include <errno.h>
7598#include <sys/stat.h>
7599#include <stdlib.h>
7600#include <fcntl.h>
7601#include <setjmp.h>
7602#ifdef HAVE_UNISTD_H
7603#include <unistd.h>
7604#endif
7605
7606#include "lisp.h"
7607#include "systime.h"
7608#include "character.h"
7609#include "coding.h"
7610#include "termopts.h"
7611#include "sysselect.h"
7612
7613extern int frame_garbaged;
7614
7615extern EMACS_TIME timer_check ();
7616extern int timers_run;
7617
7618Lisp_Object QCtype, QCname;
7619
7620Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
7621Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
7622Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
7623Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
7624
7625/* As described above, except assuming that there are no subprocesses:
7626
7627 Wait for timeout to elapse and/or keyboard input to be available.
7628
7629 time_limit is:
7630 timeout in seconds, or
7631 zero for no limit, or
7632 -1 means gobble data immediately available but don't wait for any.
7633 7632
7634 read_kbd is a Lisp_Object: 7633#endif /* subprocesses */
7635 0 to ignore keyboard input, or
7636 1 to return when input is available, or
7637 -1 means caller will actually read the input, so don't throw to
7638 the quit handler.
7639
7640 see full version for other parameters. We know that wait_proc will
7641 always be NULL, since `subprocesses' isn't defined.
7642
7643 do_display != 0 means redisplay should be done to show subprocess
7644 output that arrives.
7645
7646 Return true if we received input from any process. */
7647
7648int
7649wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
7650 wait_for_cell, wait_proc, just_wait_proc)
7651 int time_limit, microsecs, read_kbd, do_display;
7652 Lisp_Object wait_for_cell;
7653 struct Lisp_Process *wait_proc;
7654 int just_wait_proc;
7655{
7656 register int nfds;
7657 EMACS_TIME end_time, timeout;
7658 SELECT_TYPE waitchannels;
7659 int xerrno;
7660
7661 /* What does time_limit really mean? */
7662 if (time_limit || microsecs)
7663 {
7664 EMACS_GET_TIME (end_time);
7665 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs);
7666 EMACS_ADD_TIME (end_time, end_time, timeout);
7667 }
7668
7669 /* Turn off periodic alarms (in case they are in use)
7670 and then turn off any other atimers,
7671 because the select emulator uses alarms. */
7672 stop_polling ();
7673 turn_on_atimers (0);
7674
7675 while (1)
7676 {
7677 int timeout_reduced_for_timers = 0;
7678
7679 /* If calling from keyboard input, do not quit
7680 since we want to return C-g as an input character.
7681 Otherwise, do pending quit if requested. */
7682 if (read_kbd >= 0)
7683 QUIT;
7684
7685 /* Exit now if the cell we're waiting for became non-nil. */
7686 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
7687 break;
7688
7689 /* Compute time from now till when time limit is up */
7690 /* Exit if already run out */
7691 if (time_limit == -1)
7692 {
7693 /* -1 specified for timeout means
7694 gobble output available now
7695 but don't wait at all. */
7696
7697 EMACS_SET_SECS_USECS (timeout, 0, 0);
7698 }
7699 else if (time_limit || microsecs)
7700 {
7701 EMACS_GET_TIME (timeout);
7702 EMACS_SUB_TIME (timeout, end_time, timeout);
7703 if (EMACS_TIME_NEG_P (timeout))
7704 break;
7705 }
7706 else
7707 {
7708 EMACS_SET_SECS_USECS (timeout, 100000, 0);
7709 }
7710
7711 /* If our caller will not immediately handle keyboard events,
7712 run timer events directly.
7713 (Callers that will immediately read keyboard events
7714 call timer_delay on their own.) */
7715 if (NILP (wait_for_cell))
7716 {
7717 EMACS_TIME timer_delay;
7718
7719 do
7720 {
7721 int old_timers_run = timers_run;
7722 timer_delay = timer_check (1);
7723 if (timers_run != old_timers_run && do_display)
7724 /* We must retry, since a timer may have requeued itself
7725 and that could alter the time delay. */
7726 redisplay_preserve_echo_area (14);
7727 else
7728 break;
7729 }
7730 while (!detect_input_pending ());
7731
7732 /* If there is unread keyboard input, also return. */
7733 if (read_kbd != 0
7734 && requeued_events_pending_p ())
7735 break;
7736
7737 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1)
7738 {
7739 EMACS_TIME difference;
7740 EMACS_SUB_TIME (difference, timer_delay, timeout);
7741 if (EMACS_TIME_NEG_P (difference))
7742 {
7743 timeout = timer_delay;
7744 timeout_reduced_for_timers = 1;
7745 }
7746 }
7747 }
7748
7749 /* Cause C-g and alarm signals to take immediate action,
7750 and cause input available signals to zero out timeout. */
7751 if (read_kbd < 0)
7752 set_waiting_for_input (&timeout);
7753
7754 /* Wait till there is something to do. */
7755
7756 if (! read_kbd && NILP (wait_for_cell))
7757 FD_ZERO (&waitchannels);
7758 else
7759 FD_SET (0, &waitchannels);
7760
7761 /* If a frame has been newly mapped and needs updating,
7762 reprocess its display stuff. */
7763 if (frame_garbaged && do_display)
7764 {
7765 clear_waiting_for_input ();
7766 redisplay_preserve_echo_area (15);
7767 if (read_kbd < 0)
7768 set_waiting_for_input (&timeout);
7769 }
7770
7771 if (read_kbd && detect_input_pending ())
7772 {
7773 nfds = 0;
7774 FD_ZERO (&waitchannels);
7775 }
7776 else
7777 nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0,
7778 &timeout);
7779
7780 xerrno = errno;
7781
7782 /* Make C-g and alarm signals set flags again */
7783 clear_waiting_for_input ();
7784
7785 /* If we woke up due to SIGWINCH, actually change size now. */
7786 do_pending_window_change (0);
7787
7788 if (time_limit && nfds == 0 && ! timeout_reduced_for_timers)
7789 /* We waited the full specified time, so return now. */
7790 break;
7791
7792 if (nfds == -1)
7793 {
7794 /* If the system call was interrupted, then go around the
7795 loop again. */
7796 if (xerrno == EINTR)
7797 FD_ZERO (&waitchannels);
7798 else
7799 error ("select error: %s", emacs_strerror (xerrno));
7800 }
7801#ifdef SOLARIS2
7802 else if (nfds > 0 && (waitchannels & 1) && interrupt_input)
7803 /* System sometimes fails to deliver SIGIO. */
7804 kill (getpid (), SIGIO);
7805#endif
7806#ifdef SIGIO
7807 if (read_kbd && interrupt_input && (waitchannels & 1))
7808 kill (getpid (), SIGIO);
7809#endif
7810
7811 /* Check for keyboard input */
7812
7813 if (read_kbd
7814 && detect_input_pending_run_timers (do_display))
7815 {
7816 swallow_events (do_display);
7817 if (detect_input_pending_run_timers (do_display))
7818 break;
7819 }
7820
7821 /* If there is unread keyboard input, also return. */
7822 if (read_kbd
7823 && requeued_events_pending_p ())
7824 break;
7825
7826 /* If wait_for_cell. check for keyboard input
7827 but don't run any timers.
7828 ??? (It seems wrong to me to check for keyboard
7829 input at all when wait_for_cell, but the code
7830 has been this way since July 1994.
7831 Try changing this after version 19.31.) */
7832 if (! NILP (wait_for_cell)
7833 && detect_input_pending ())
7834 {
7835 swallow_events (do_display);
7836 if (detect_input_pending ())
7837 break;
7838 }
7839
7840 /* Exit now if the cell we're waiting for became non-nil. */
7841 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
7842 break;
7843 }
7844
7845 start_polling ();
7846
7847 return 0;
7848}
7849
7850
7851/* Don't confuse make-docfile by having two doc strings for this function.
7852 make-docfile does not pay attention to #if, for good reason! */
7853DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
7854 0)
7855 (name)
7856 register Lisp_Object name;
7857{
7858 return Qnil;
7859}
7860
7861 /* Don't confuse make-docfile by having two doc strings for this function.
7862 make-docfile does not pay attention to #if, for good reason! */
7863DEFUN ("process-inherit-coding-system-flag",
7864 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
7865 1, 1, 0,
7866 0)
7867 (process)
7868 register Lisp_Object process;
7869{
7870 /* Ignore the argument and return the value of
7871 inherit-process-coding-system. */
7872 return inherit_process_coding_system ? Qt : Qnil;
7873}
7874
7875/* Kill all processes associated with `buffer'.
7876 If `buffer' is nil, kill all processes.
7877 Since we have no subprocesses, this does nothing. */
7878
7879void
7880kill_buffer_processes (buffer)
7881 Lisp_Object buffer;
7882{
7883}
7884
7885DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes,
7886 0, 0, 0,
7887 doc: /* Return a list of numerical process IDs of all running processes.
7888If this functionality is unsupported, return nil.
7889
7890See `process-attributes' for getting attributes of a process given its ID. */)
7891 ()
7892{
7893 return list_system_processes ();
7894}
7895
7896DEFUN ("process-attributes", Fprocess_attributes,
7897 Sprocess_attributes, 1, 1, 0,
7898 doc: /* Return attributes of the process given by its PID, a number.
7899
7900Value is an alist where each element is a cons cell of the form
7901
7902 \(KEY . VALUE)
7903
7904If this functionality is unsupported, the value is nil.
7905
7906See `list-system-processes' for getting a list of all process IDs.
7907
7908The KEYs of the attributes that this function may return are listed
7909below, together with the type of the associated VALUE (in parentheses).
7910Not all platforms support all of these attributes; unsupported
7911attributes will not appear in the returned alist.
7912Unless explicitly indicated otherwise, numbers can have either
7913integer or floating point values.
7914
7915 euid -- Effective user User ID of the process (number)
7916 user -- User name corresponding to euid (string)
7917 egid -- Effective user Group ID of the process (number)
7918 group -- Group name corresponding to egid (string)
7919 comm -- Command name (executable name only) (string)
7920 state -- Process state code, such as "S", "R", or "T" (string)
7921 ppid -- Parent process ID (number)
7922 pgrp -- Process group ID (number)
7923 sess -- Session ID, i.e. process ID of session leader (number)
7924 ttname -- Controlling tty name (string)
7925 tpgid -- ID of foreground process group on the process's tty (number)
7926 minflt -- number of minor page faults (number)
7927 majflt -- number of major page faults (number)
7928 cminflt -- cumulative number of minor page faults (number)
7929 cmajflt -- cumulative number of major page faults (number)
7930 utime -- user time used by the process, in the (HIGH LOW USEC) format
7931 stime -- system time used by the process, in the (HIGH LOW USEC) format
7932 time -- sum of utime and stime, in the (HIGH LOW USEC) format
7933 cutime -- user time used by the process and its children, (HIGH LOW USEC)
7934 cstime -- system time used by the process and its children, (HIGH LOW USEC)
7935 ctime -- sum of cutime and cstime, in the (HIGH LOW USEC) format
7936 pri -- priority of the process (number)
7937 nice -- nice value of the process (number)
7938 thcount -- process thread count (number)
7939 start -- time the process started, in the (HIGH LOW USEC) format
7940 vsize -- virtual memory size of the process in KB's (number)
7941 rss -- resident set size of the process in KB's (number)
7942 etime -- elapsed time the process is running, in (HIGH LOW USEC) format
7943 pcpu -- percents of CPU time used by the process (floating-point number)
7944 pmem -- percents of total physical memory used by process's resident set
7945 (floating-point number)
7946 args -- command line which invoked the process (string). */)
7947 (pid)
7948
7949 Lisp_Object pid;
7950{
7951 return system_process_attributes (pid);
7952}
7953
7954void
7955init_process ()
7956{
7957}
7958
7959void
7960syms_of_process ()
7961{
7962 QCtype = intern_c_string (":type");
7963 staticpro (&QCtype);
7964 QCname = intern_c_string (":name");
7965 staticpro (&QCname);
7966 QCtype = intern_c_string (":type");
7967 staticpro (&QCtype);
7968 QCname = intern_c_string (":name");
7969 staticpro (&QCname);
7970 Qeuid = intern_c_string ("euid");
7971 staticpro (&Qeuid);
7972 Qegid = intern_c_string ("egid");
7973 staticpro (&Qegid);
7974 Quser = intern_c_string ("user");
7975 staticpro (&Quser);
7976 Qgroup = intern_c_string ("group");
7977 staticpro (&Qgroup);
7978 Qcomm = intern_c_string ("comm");
7979 staticpro (&Qcomm);
7980 Qstate = intern_c_string ("state");
7981 staticpro (&Qstate);
7982 Qppid = intern_c_string ("ppid");
7983 staticpro (&Qppid);
7984 Qpgrp = intern_c_string ("pgrp");
7985 staticpro (&Qpgrp);
7986 Qsess = intern_c_string ("sess");
7987 staticpro (&Qsess);
7988 Qttname = intern_c_string ("ttname");
7989 staticpro (&Qttname);
7990 Qtpgid = intern_c_string ("tpgid");
7991 staticpro (&Qtpgid);
7992 Qminflt = intern_c_string ("minflt");
7993 staticpro (&Qminflt);
7994 Qmajflt = intern_c_string ("majflt");
7995 staticpro (&Qmajflt);
7996 Qcminflt = intern_c_string ("cminflt");
7997 staticpro (&Qcminflt);
7998 Qcmajflt = intern_c_string ("cmajflt");
7999 staticpro (&Qcmajflt);
8000 Qutime = intern_c_string ("utime");
8001 staticpro (&Qutime);
8002 Qstime = intern_c_string ("stime");
8003 staticpro (&Qstime);
8004 Qtime = intern_c_string ("time");
8005 staticpro (&Qtime);
8006 Qcutime = intern_c_string ("cutime");
8007 staticpro (&Qcutime);
8008 Qcstime = intern_c_string ("cstime");
8009 staticpro (&Qcstime);
8010 Qctime = intern_c_string ("ctime");
8011 staticpro (&Qctime);
8012 Qpri = intern_c_string ("pri");
8013 staticpro (&Qpri);
8014 Qnice = intern_c_string ("nice");
8015 staticpro (&Qnice);
8016 Qthcount = intern_c_string ("thcount");
8017 staticpro (&Qthcount);
8018 Qstart = intern_c_string ("start");
8019 staticpro (&Qstart);
8020 Qvsize = intern_c_string ("vsize");
8021 staticpro (&Qvsize);
8022 Qrss = intern_c_string ("rss");
8023 staticpro (&Qrss);
8024 Qetime = intern_c_string ("etime");
8025 staticpro (&Qetime);
8026 Qpcpu = intern_c_string ("pcpu");
8027 staticpro (&Qpcpu);
8028 Qpmem = intern_c_string ("pmem");
8029 staticpro (&Qpmem);
8030 Qargs = intern_c_string ("args");
8031 staticpro (&Qargs);
8032 7634
8033 defsubr (&Sget_buffer_process); 7635 defsubr (&Sget_buffer_process);
8034 defsubr (&Sprocess_inherit_coding_system_flag); 7636 defsubr (&Sprocess_inherit_coding_system_flag);
@@ -8036,8 +7638,5 @@ syms_of_process ()
8036 defsubr (&Sprocess_attributes); 7638 defsubr (&Sprocess_attributes);
8037} 7639}
8038 7640
8039
8040#endif /* not subprocesses */
8041
8042/* arch-tag: 3706c011-7b9a-4117-bd4f-59e7f701a4c4 7641/* arch-tag: 3706c011-7b9a-4117-bd4f-59e7f701a4c4
8043 (do not change this comment) */ 7642 (do not change this comment) */