aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKenichi Handa2010-07-08 17:09:35 +0900
committerKenichi Handa2010-07-08 17:09:35 +0900
commit80d4189187791916590b6c2b20b54588d432bb75 (patch)
treee59e52ee4a456f3235bff0e7fba4362681dba7dd /src/process.c
parenta7840ffb291e13c2a2386ccbd58089e1d7461c16 (diff)
parent0216627eb39f77958e30f4750f581714fdfd7faf (diff)
downloademacs-80d4189187791916590b6c2b20b54588d432bb75.tar.gz
emacs-80d4189187791916590b6c2b20b54588d432bb75.zip
merge trunk
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c280
1 files changed, 128 insertions, 152 deletions
diff --git a/src/process.c b/src/process.c
index 24f31220d0d..67052cac720 100644
--- a/src/process.c
+++ b/src/process.c
@@ -182,7 +182,7 @@ Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
182 182
183#include "syswait.h" 183#include "syswait.h"
184 184
185extern char *get_operating_system_release (); 185extern char *get_operating_system_release (void);
186 186
187/* Serial processes require termios or Windows. */ 187/* Serial processes require termios or Windows. */
188#if defined (HAVE_TERMIOS) || defined (WINDOWSNT) 188#if defined (HAVE_TERMIOS) || defined (WINDOWSNT)
@@ -285,11 +285,11 @@ static Lisp_Object Vprocess_adaptive_read_buffering;
285 285
286#include "sysselect.h" 286#include "sysselect.h"
287 287
288static int keyboard_bit_set P_ ((SELECT_TYPE *)); 288static int keyboard_bit_set (SELECT_TYPE *);
289static void deactivate_process P_ ((Lisp_Object)); 289static void deactivate_process (Lisp_Object);
290static void status_notify P_ ((struct Lisp_Process *)); 290static void status_notify (struct Lisp_Process *);
291static int read_process_output P_ ((Lisp_Object, int)); 291static int read_process_output (Lisp_Object, int);
292static void create_pty P_ ((Lisp_Object)); 292static void create_pty (Lisp_Object);
293 293
294/* If we support a window system, turn on the code to poll periodically 294/* 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. */ 295 to detect C-g. It isn't actually used when doing interrupt input. */
@@ -297,8 +297,8 @@ static void create_pty P_ ((Lisp_Object));
297#define POLL_FOR_INPUT 297#define POLL_FOR_INPUT
298#endif 298#endif
299 299
300static Lisp_Object get_process (); 300static Lisp_Object get_process (register Lisp_Object name);
301static void exec_sentinel (); 301static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
302 302
303extern int timers_run; 303extern int timers_run;
304 304
@@ -306,6 +306,10 @@ extern int timers_run;
306 306
307static SELECT_TYPE input_wait_mask; 307static SELECT_TYPE input_wait_mask;
308 308
309/* Non-zero if keyboard input is on hold, zero otherwise. */
310
311static int kbd_is_on_hold;
312
309/* Mask that excludes keyboard input descriptor(s). */ 313/* Mask that excludes keyboard input descriptor(s). */
310 314
311static SELECT_TYPE non_keyboard_wait_mask; 315static SELECT_TYPE non_keyboard_wait_mask;
@@ -399,8 +403,7 @@ static char pty_name[24];
399static Lisp_Object status_convert (int); 403static Lisp_Object status_convert (int);
400 404
401static void 405static void
402update_status (p) 406update_status (struct Lisp_Process *p)
403 struct Lisp_Process *p;
404{ 407{
405 eassert (p->raw_status_new); 408 eassert (p->raw_status_new);
406 p->status = status_convert (p->raw_status); 409 p->status = status_convert (p->raw_status);
@@ -429,11 +432,7 @@ status_convert (int w)
429 and store them individually through the three pointers. */ 432 and store them individually through the three pointers. */
430 433
431static void 434static void
432decode_status (l, symbol, code, coredump) 435decode_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{ 436{
438 Lisp_Object tem; 437 Lisp_Object tem;
439 438
@@ -456,8 +455,7 @@ decode_status (l, symbol, code, coredump)
456/* Return a string describing a process status list. */ 455/* Return a string describing a process status list. */
457 456
458static Lisp_Object 457static Lisp_Object
459status_message (p) 458status_message (struct Lisp_Process *p)
460 struct Lisp_Process *p;
461{ 459{
462 Lisp_Object status = p->status; 460 Lisp_Object status = p->status;
463 Lisp_Object symbol; 461 Lisp_Object symbol;
@@ -519,7 +517,7 @@ status_message (p)
519 is left in the variable pty_name. */ 517 is left in the variable pty_name. */
520 518
521static int 519static int
522allocate_pty () 520allocate_pty (void)
523{ 521{
524 register int c, i; 522 register int c, i;
525 int fd; 523 int fd;
@@ -593,8 +591,7 @@ allocate_pty ()
593#endif /* HAVE_PTYS */ 591#endif /* HAVE_PTYS */
594 592
595static Lisp_Object 593static Lisp_Object
596make_process (name) 594make_process (Lisp_Object name)
597 Lisp_Object name;
598{ 595{
599 register Lisp_Object val, tem, name1; 596 register Lisp_Object val, tem, name1;
600 register struct Lisp_Process *p; 597 register struct Lisp_Process *p;
@@ -638,8 +635,7 @@ make_process (name)
638} 635}
639 636
640static void 637static void
641remove_process (proc) 638remove_process (register Lisp_Object proc)
642 register Lisp_Object proc;
643{ 639{
644 register Lisp_Object pair; 640 register Lisp_Object pair;
645 641
@@ -652,8 +648,7 @@ remove_process (proc)
652/* Setup coding systems of PROCESS. */ 648/* Setup coding systems of PROCESS. */
653 649
654void 650void
655setup_process_coding_systems (process) 651setup_process_coding_systems (Lisp_Object process)
656 Lisp_Object process;
657{ 652{
658 struct Lisp_Process *p = XPROCESS (process); 653 struct Lisp_Process *p = XPROCESS (process);
659 int inch = p->infd; 654 int inch = p->infd;
@@ -729,8 +724,7 @@ BUFFER may be a buffer or the name of one. */)
729 current buffer. */ 724 current buffer. */
730 725
731static Lisp_Object 726static Lisp_Object
732get_process (name) 727get_process (register Lisp_Object name)
733 register Lisp_Object name;
734{ 728{
735 register Lisp_Object proc, obj; 729 register Lisp_Object proc, obj;
736 if (STRINGP (name)) 730 if (STRINGP (name))
@@ -1161,7 +1155,7 @@ DEFUN ("process-query-on-exit-flag",
1161} 1155}
1162 1156
1163#ifdef DATAGRAM_SOCKETS 1157#ifdef DATAGRAM_SOCKETS
1164Lisp_Object Fprocess_datagram_address (); 1158Lisp_Object Fprocess_datagram_address (Lisp_Object process);
1165#endif 1159#endif
1166 1160
1167DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, 1161DEFUN ("process-contact", Fprocess_contact, Sprocess_contact,
@@ -1327,8 +1321,7 @@ Returns nil if format of ADDRESS is invalid. */)
1327#endif 1321#endif
1328 1322
1329static Lisp_Object 1323static Lisp_Object
1330list_processes_1 (query_only) 1324list_processes_1 (Lisp_Object query_only)
1331 Lisp_Object query_only;
1332{ 1325{
1333 register Lisp_Object tail, tem; 1326 register Lisp_Object tail, tem;
1334 Lisp_Object proc, minspace, tem1; 1327 Lisp_Object proc, minspace, tem1;
@@ -1579,7 +1572,7 @@ DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0,
1579 1572
1580/* Starting asynchronous inferior processes. */ 1573/* Starting asynchronous inferior processes. */
1581 1574
1582static Lisp_Object start_process_unwind (); 1575static Lisp_Object start_process_unwind (Lisp_Object proc);
1583 1576
1584DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, 1577DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0,
1585 doc: /* Start a program in a subprocess. Return the process object for it. 1578 doc: /* Start a program in a subprocess. Return the process object for it.
@@ -1814,8 +1807,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1814 an error and the process wasn't started successfully, so we should 1807 an error and the process wasn't started successfully, so we should
1815 remove it from the process list. */ 1808 remove it from the process list. */
1816static Lisp_Object 1809static Lisp_Object
1817start_process_unwind (proc) 1810start_process_unwind (Lisp_Object proc)
1818 Lisp_Object proc;
1819{ 1811{
1820 if (!PROCESSP (proc)) 1812 if (!PROCESSP (proc))
1821 abort (); 1813 abort ();
@@ -1828,8 +1820,7 @@ start_process_unwind (proc)
1828} 1820}
1829 1821
1830static void 1822static void
1831create_process_1 (timer) 1823create_process_1 (struct atimer *timer)
1832 struct atimer *timer;
1833{ 1824{
1834 /* Nothing to do. */ 1825 /* Nothing to do. */
1835} 1826}
@@ -1855,10 +1846,7 @@ create_process_sigchld ()
1855#endif 1846#endif
1856 1847
1857void 1848void
1858create_process (process, new_argv, current_dir) 1849create_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{ 1850{
1863 int inchannel, outchannel; 1851 int inchannel, outchannel;
1864 pid_t pid; 1852 pid_t pid;
@@ -2245,8 +2233,7 @@ create_process (process, new_argv, current_dir)
2245} 2233}
2246 2234
2247void 2235void
2248create_pty (process) 2236create_pty (Lisp_Object process)
2249 Lisp_Object process;
2250{ 2237{
2251 int inchannel, outchannel; 2238 int inchannel, outchannel;
2252 2239
@@ -2333,9 +2320,7 @@ create_pty (process)
2333 The address family of sa is not included in the result. */ 2320 The address family of sa is not included in the result. */
2334 2321
2335static Lisp_Object 2322static Lisp_Object
2336conv_sockaddr_to_lisp (sa, len) 2323conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
2337 struct sockaddr *sa;
2338 int len;
2339{ 2324{
2340 Lisp_Object address; 2325 Lisp_Object address;
2341 int i; 2326 int i;
@@ -2404,9 +2389,7 @@ conv_sockaddr_to_lisp (sa, len)
2404/* Get family and required size for sockaddr structure to hold ADDRESS. */ 2389/* Get family and required size for sockaddr structure to hold ADDRESS. */
2405 2390
2406static int 2391static int
2407get_lisp_to_sockaddr_size (address, familyp) 2392get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp)
2408 Lisp_Object address;
2409 int *familyp;
2410{ 2393{
2411 register struct Lisp_Vector *p; 2394 register struct Lisp_Vector *p;
2412 2395
@@ -2451,17 +2434,13 @@ get_lisp_to_sockaddr_size (address, familyp)
2451 we return after zeroing *SA. */ 2434 we return after zeroing *SA. */
2452 2435
2453static void 2436static void
2454conv_lisp_to_sockaddr (family, address, sa, len) 2437conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int len)
2455 int family;
2456 Lisp_Object address;
2457 struct sockaddr *sa;
2458 int len;
2459{ 2438{
2460 register struct Lisp_Vector *p; 2439 register struct Lisp_Vector *p;
2461 register unsigned char *cp = NULL; 2440 register unsigned char *cp = NULL;
2462 register int i; 2441 register int i;
2463 2442
2464 bzero (sa, len); 2443 memset (sa, 0, len);
2465 2444
2466 if (VECTORP (address)) 2445 if (VECTORP (address))
2467 { 2446 {
@@ -2612,9 +2591,7 @@ static const struct socket_options {
2612*/ 2591*/
2613 2592
2614static int 2593static int
2615set_socket_option (s, opt, val) 2594set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
2616 int s;
2617 Lisp_Object opt, val;
2618{ 2595{
2619 char *name; 2596 char *name;
2620 const struct socket_options *sopt; 2597 const struct socket_options *sopt;
@@ -2658,12 +2635,12 @@ set_socket_option (s, opt, val)
2658 /* This is broken, at least in the Linux 2.4 kernel. 2635 /* This is broken, at least in the Linux 2.4 kernel.
2659 To unbind, the arg must be a zero integer, not the empty string. 2636 To unbind, the arg must be a zero integer, not the empty string.
2660 This should work on all systems. KFS. 2003-09-23. */ 2637 This should work on all systems. KFS. 2003-09-23. */
2661 bzero (devname, sizeof devname); 2638 memset (devname, 0, sizeof devname);
2662 if (STRINGP (val)) 2639 if (STRINGP (val))
2663 { 2640 {
2664 char *arg = (char *) SDATA (val); 2641 char *arg = (char *) SDATA (val);
2665 int len = min (strlen (arg), IFNAMSIZ); 2642 int len = min (strlen (arg), IFNAMSIZ);
2666 bcopy (arg, devname, len); 2643 memcpy (devname, arg, len);
2667 } 2644 }
2668 else if (!NILP (val)) 2645 else if (!NILP (val))
2669 error ("Bad option value for %s", name); 2646 error ("Bad option value for %s", name);
@@ -3030,7 +3007,7 @@ usage: (make-serial-process &rest ARGS) */)
3030 p->inherit_coding_system_flag 3007 p->inherit_coding_system_flag
3031 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); 3008 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
3032 3009
3033 Fserial_process_configure(nargs, args); 3010 Fserial_process_configure (nargs, args);
3034 3011
3035 specpdl_ptr = specpdl + specpdl_count; 3012 specpdl_ptr = specpdl + specpdl_count;
3036 3013
@@ -3372,7 +3349,7 @@ usage: (make-network-process &rest ARGS) */)
3372 host = Qnil; 3349 host = Qnil;
3373 } 3350 }
3374 CHECK_STRING (service); 3351 CHECK_STRING (service);
3375 bzero (&address_un, sizeof address_un); 3352 memset (&address_un, 0, sizeof address_un);
3376 address_un.sun_family = AF_LOCAL; 3353 address_un.sun_family = AF_LOCAL;
3377 strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path); 3354 strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path);
3378 ai.ai_addr = (struct sockaddr *) &address_un; 3355 ai.ai_addr = (struct sockaddr *) &address_un;
@@ -3428,7 +3405,7 @@ usage: (make-network-process &rest ARGS) */)
3428 ret = getaddrinfo (SDATA (host), portstring, &hints, &res); 3405 ret = getaddrinfo (SDATA (host), portstring, &hints, &res);
3429 if (ret) 3406 if (ret)
3430#ifdef HAVE_GAI_STRERROR 3407#ifdef HAVE_GAI_STRERROR
3431 error ("%s/%s %s", SDATA (host), portstring, gai_strerror(ret)); 3408 error ("%s/%s %s", SDATA (host), portstring, gai_strerror (ret));
3432#else 3409#else
3433 error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret); 3410 error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret);
3434#endif 3411#endif
@@ -3456,7 +3433,7 @@ usage: (make-network-process &rest ARGS) */)
3456 port = svc_info->s_port; 3433 port = svc_info->s_port;
3457 } 3434 }
3458 3435
3459 bzero (&address_in, sizeof address_in); 3436 memset (&address_in, 0, sizeof address_in);
3460 address_in.sin_family = family; 3437 address_in.sin_family = family;
3461 address_in.sin_addr.s_addr = INADDR_ANY; 3438 address_in.sin_addr.s_addr = INADDR_ANY;
3462 address_in.sin_port = port; 3439 address_in.sin_port = port;
@@ -3480,8 +3457,8 @@ usage: (make-network-process &rest ARGS) */)
3480 3457
3481 if (host_info_ptr) 3458 if (host_info_ptr)
3482 { 3459 {
3483 bcopy (host_info_ptr->h_addr, (char *) &address_in.sin_addr, 3460 memcpy (&address_in.sin_addr, host_info_ptr->h_addr,
3484 host_info_ptr->h_length); 3461 host_info_ptr->h_length);
3485 family = host_info_ptr->h_addrtype; 3462 family = host_info_ptr->h_addrtype;
3486 address_in.sin_family = family; 3463 address_in.sin_family = family;
3487 } 3464 }
@@ -3493,8 +3470,8 @@ usage: (make-network-process &rest ARGS) */)
3493 if (numeric_addr == -1) 3470 if (numeric_addr == -1)
3494 error ("Unknown host \"%s\"", SDATA (host)); 3471 error ("Unknown host \"%s\"", SDATA (host));
3495 3472
3496 bcopy ((char *)&numeric_addr, (char *) &address_in.sin_addr, 3473 memcpy (&address_in.sin_addr, &numeric_addr,
3497 sizeof (address_in.sin_addr)); 3474 sizeof (address_in.sin_addr));
3498 } 3475 }
3499 3476
3500 } 3477 }
@@ -3678,7 +3655,7 @@ usage: (make-network-process &rest ARGS) */)
3678 if (is_server) 3655 if (is_server)
3679 { 3656 {
3680 Lisp_Object remote; 3657 Lisp_Object remote;
3681 bzero (datagram_address[s].sa, lres->ai_addrlen); 3658 memset (datagram_address[s].sa, 0, lres->ai_addrlen);
3682 if (remote = Fplist_get (contact, QCremote), !NILP (remote)) 3659 if (remote = Fplist_get (contact, QCremote), !NILP (remote))
3683 { 3660 {
3684 int rfamily, rlen; 3661 int rfamily, rlen;
@@ -3689,7 +3666,7 @@ usage: (make-network-process &rest ARGS) */)
3689 } 3666 }
3690 } 3667 }
3691 else 3668 else
3692 bcopy (lres->ai_addr, datagram_address[s].sa, lres->ai_addrlen); 3669 memcpy (datagram_address[s].sa, lres->ai_addr, lres->ai_addrlen);
3693 } 3670 }
3694#endif 3671#endif
3695 contact = Fplist_put (contact, QCaddress, 3672 contact = Fplist_put (contact, QCaddress,
@@ -3701,7 +3678,7 @@ usage: (make-network-process &rest ARGS) */)
3701 int len1 = sizeof (sa1); 3678 int len1 = sizeof (sa1);
3702 if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) 3679 if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
3703 contact = Fplist_put (contact, QClocal, 3680 contact = Fplist_put (contact, QClocal,
3704 conv_sockaddr_to_lisp (&sa1, len1)); 3681 conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1));
3705 } 3682 }
3706#endif 3683#endif
3707 } 3684 }
@@ -3927,7 +3904,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3927 3904
3928 again: 3905 again:
3929 ifaces += 25; 3906 ifaces += 25;
3930 buf_size = ifaces * sizeof(ifreqs[0]); 3907 buf_size = ifaces * sizeof (ifreqs[0]);
3931 ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size); 3908 ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size);
3932 if (!ifreqs) 3909 if (!ifreqs)
3933 { 3910 {
@@ -3956,7 +3933,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3956 char namebuf[sizeof (ifq->ifr_name) + 1]; 3933 char namebuf[sizeof (ifq->ifr_name) + 1];
3957 if (ifq->ifr_addr.sa_family != AF_INET) 3934 if (ifq->ifr_addr.sa_family != AF_INET)
3958 continue; 3935 continue;
3959 bcopy (ifq->ifr_name, namebuf, sizeof (ifq->ifr_name)); 3936 memcpy (namebuf, ifq->ifr_name, sizeof (ifq->ifr_name));
3960 namebuf[sizeof (ifq->ifr_name)] = 0; 3937 namebuf[sizeof (ifq->ifr_name)] = 0;
3961 res = Fcons (Fcons (build_string (namebuf), 3938 res = Fcons (Fcons (build_string (namebuf),
3962 conv_sockaddr_to_lisp (&ifq->ifr_addr, 3939 conv_sockaddr_to_lisp (&ifq->ifr_addr,
@@ -4059,7 +4036,7 @@ FLAGS is the current flags of the interface. */)
4059 4036
4060 CHECK_STRING (ifname); 4037 CHECK_STRING (ifname);
4061 4038
4062 bzero (rq.ifr_name, sizeof rq.ifr_name); 4039 memset (rq.ifr_name, 0, sizeof rq.ifr_name);
4063 strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name)); 4040 strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name));
4064 4041
4065 s = socket (AF_INET, SOCK_STREAM, 0); 4042 s = socket (AF_INET, SOCK_STREAM, 0);
@@ -4154,8 +4131,7 @@ FLAGS is the current flags of the interface. */)
4154/* Turn off input and output for process PROC. */ 4131/* Turn off input and output for process PROC. */
4155 4132
4156void 4133void
4157deactivate_process (proc) 4134deactivate_process (Lisp_Object proc)
4158 Lisp_Object proc;
4159{ 4135{
4160 register int inchannel, outchannel; 4136 register int inchannel, outchannel;
4161 register struct Lisp_Process *p = XPROCESS (proc); 4137 register struct Lisp_Process *p = XPROCESS (proc);
@@ -4220,7 +4196,7 @@ deactivate_process (proc)
4220 to get rid of irrelevant descriptors. */ 4196 to get rid of irrelevant descriptors. */
4221 4197
4222void 4198void
4223close_process_descs () 4199close_process_descs (void)
4224{ 4200{
4225#ifndef WINDOWSNT 4201#ifndef WINDOWSNT
4226 int i; 4202 int i;
@@ -4313,9 +4289,7 @@ Return non-nil if we received any output before the timeout expired. */)
4313static int connect_counter = 0; 4289static int connect_counter = 0;
4314 4290
4315static void 4291static void
4316server_accept_connection (server, channel) 4292server_accept_connection (Lisp_Object server, int channel)
4317 Lisp_Object server;
4318 int channel;
4319{ 4293{
4320 Lisp_Object proc, caller, name, buffer; 4294 Lisp_Object proc, caller, name, buffer;
4321 Lisp_Object contact, host, service; 4295 Lisp_Object contact, host, service;
@@ -4392,7 +4366,7 @@ server_accept_connection (server, channel)
4392 int i; 4366 int i;
4393 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x"); 4367 args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x");
4394 for (i = 0; i < 8; i++) 4368 for (i = 0; i < 8; i++)
4395 args[i+1] = make_number (ntohs(ip6[i])); 4369 args[i+1] = make_number (ntohs (ip6[i]));
4396 host = Fformat (9, args); 4370 host = Fformat (9, args);
4397 service = make_number (ntohs (saddr.in.sin_port)); 4371 service = make_number (ntohs (saddr.in.sin_port));
4398 4372
@@ -4531,8 +4505,7 @@ server_accept_connection (server, channel)
4531static int waiting_for_user_input_p; 4505static int waiting_for_user_input_p;
4532 4506
4533static Lisp_Object 4507static Lisp_Object
4534wait_reading_process_output_unwind (data) 4508wait_reading_process_output_unwind (Lisp_Object data)
4535 Lisp_Object data;
4536{ 4509{
4537 waiting_for_user_input_p = XINT (data); 4510 waiting_for_user_input_p = XINT (data);
4538 return Qnil; 4511 return Qnil;
@@ -4540,7 +4513,7 @@ wait_reading_process_output_unwind (data)
4540 4513
4541/* This is here so breakpoints can be put on it. */ 4514/* This is here so breakpoints can be put on it. */
4542static void 4515static void
4543wait_reading_process_output_1 () 4516wait_reading_process_output_1 (void)
4544{ 4517{
4545} 4518}
4546 4519
@@ -4553,10 +4526,7 @@ wait_reading_process_output_1 ()
4553 4526
4554#ifndef select 4527#ifndef select
4555static INLINE int 4528static INLINE int
4556select_wrapper (n, rfd, wfd, xfd, tmo) 4529select_wrapper (int n, fd_set *rfd, fd_set *wfd, fd_set *xfd, struct timeval *tmo)
4557 int n;
4558 SELECT_TYPE *rfd, *wfd, *xfd;
4559 EMACS_TIME *tmo;
4560{ 4530{
4561 return select (n, rfd, wfd, xfd, tmo); 4531 return select (n, rfd, wfd, xfd, tmo);
4562} 4532}
@@ -4765,7 +4735,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4765 SELECT_TYPE Ctemp; 4735 SELECT_TYPE Ctemp;
4766#endif 4736#endif
4767 4737
4768 Atemp = input_wait_mask; 4738 if (kbd_on_hold_p ())
4739 FD_ZERO (&Atemp);
4740 else
4741 Atemp = input_wait_mask;
4769 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); 4742 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
4770 4743
4771 EMACS_SET_SECS_USECS (timeout, 0, 0); 4744 EMACS_SET_SECS_USECS (timeout, 0, 0);
@@ -5198,23 +5171,23 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
5198 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. 5171 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
5199 So only use it on systems where it is known to work. */ 5172 So only use it on systems where it is known to work. */
5200 { 5173 {
5201 int xlen = sizeof(xerrno); 5174 int xlen = sizeof (xerrno);
5202 if (getsockopt(channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) 5175 if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
5203 xerrno = errno; 5176 xerrno = errno;
5204 } 5177 }
5205#else 5178#else
5206 { 5179 {
5207 struct sockaddr pname; 5180 struct sockaddr pname;
5208 int pnamelen = sizeof(pname); 5181 int pnamelen = sizeof (pname);
5209 5182
5210 /* If connection failed, getpeername will fail. */ 5183 /* If connection failed, getpeername will fail. */
5211 xerrno = 0; 5184 xerrno = 0;
5212 if (getpeername(channel, &pname, &pnamelen) < 0) 5185 if (getpeername (channel, &pname, &pnamelen) < 0)
5213 { 5186 {
5214 /* Obtain connect failure code through error slippage. */ 5187 /* Obtain connect failure code through error slippage. */
5215 char dummy; 5188 char dummy;
5216 xerrno = errno; 5189 xerrno = errno;
5217 if (errno == ENOTCONN && read(channel, &dummy, 1) < 0) 5190 if (errno == ENOTCONN && read (channel, &dummy, 1) < 0)
5218 xerrno = errno; 5191 xerrno = errno;
5219 } 5192 }
5220 } 5193 }
@@ -5261,15 +5234,13 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
5261/* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */ 5234/* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */
5262 5235
5263static Lisp_Object 5236static Lisp_Object
5264read_process_output_call (fun_and_args) 5237read_process_output_call (Lisp_Object fun_and_args)
5265 Lisp_Object fun_and_args;
5266{ 5238{
5267 return apply1 (XCAR (fun_and_args), XCDR (fun_and_args)); 5239 return apply1 (XCAR (fun_and_args), XCDR (fun_and_args));
5268} 5240}
5269 5241
5270static Lisp_Object 5242static Lisp_Object
5271read_process_output_error_handler (error) 5243read_process_output_error_handler (Lisp_Object error)
5272 Lisp_Object error;
5273{ 5244{
5274 cmd_error_internal (error, "error in process filter: "); 5245 cmd_error_internal (error, "error in process filter: ");
5275 Vinhibit_quit = Qt; 5246 Vinhibit_quit = Qt;
@@ -5290,9 +5261,7 @@ read_process_output_error_handler (error)
5290 for decoding. */ 5261 for decoding. */
5291 5262
5292static int 5263static int
5293read_process_output (proc, channel) 5264read_process_output (Lisp_Object proc, register int channel)
5294 Lisp_Object proc;
5295 register int channel;
5296{ 5265{
5297 register int nbytes; 5266 register int nbytes;
5298 char *chars; 5267 char *chars;
@@ -5308,7 +5277,7 @@ read_process_output (proc, channel)
5308 chars = (char *) alloca (carryover + readmax); 5277 chars = (char *) alloca (carryover + readmax);
5309 if (carryover) 5278 if (carryover)
5310 /* See the comment above. */ 5279 /* See the comment above. */
5311 bcopy (SDATA (p->decoding_buf), chars, carryover); 5280 memcpy (chars, SDATA (p->decoding_buf), carryover);
5312 5281
5313#ifdef DATAGRAM_SOCKETS 5282#ifdef DATAGRAM_SOCKETS
5314 /* We have a working select, so proc_buffered_char is always -1. */ 5283 /* We have a working select, so proc_buffered_char is always -1. */
@@ -5452,8 +5421,8 @@ read_process_output (proc, channel)
5452 { 5421 {
5453 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5422 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5454 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5423 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5455 bcopy (coding->carryover, SDATA (p->decoding_buf), 5424 memcpy (SDATA (p->decoding_buf), coding->carryover,
5456 coding->carryover_bytes); 5425 coding->carryover_bytes);
5457 p->decoding_carryover = coding->carryover_bytes; 5426 p->decoding_carryover = coding->carryover_bytes;
5458 } 5427 }
5459 if (SBYTES (text) > 0) 5428 if (SBYTES (text) > 0)
@@ -5544,8 +5513,8 @@ read_process_output (proc, channel)
5544 { 5513 {
5545 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5514 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5546 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5515 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5547 bcopy (coding->carryover, SDATA (p->decoding_buf), 5516 memcpy (SDATA (p->decoding_buf), coding->carryover,
5548 coding->carryover_bytes); 5517 coding->carryover_bytes);
5549 p->decoding_carryover = coding->carryover_bytes; 5518 p->decoding_carryover = coding->carryover_bytes;
5550 } 5519 }
5551 /* Adjust the multibyteness of TEXT to that of the buffer. */ 5520 /* Adjust the multibyteness of TEXT to that of the buffer. */
@@ -5618,7 +5587,7 @@ jmp_buf send_process_frame;
5618Lisp_Object process_sent_to; 5587Lisp_Object process_sent_to;
5619 5588
5620SIGTYPE 5589SIGTYPE
5621send_process_trap () 5590send_process_trap (int ignore)
5622{ 5591{
5623 SIGNAL_THREAD_CHECK (SIGPIPE); 5592 SIGNAL_THREAD_CHECK (SIGPIPE);
5624 sigunblock (sigmask (SIGPIPE)); 5593 sigunblock (sigmask (SIGPIPE));
@@ -5636,18 +5605,15 @@ send_process_trap ()
5636 This function can evaluate Lisp code and can garbage collect. */ 5605 This function can evaluate Lisp code and can garbage collect. */
5637 5606
5638static void 5607static void
5639send_process (proc, buf, len, object) 5608send_process (volatile Lisp_Object proc, unsigned char *volatile buf,
5640 volatile Lisp_Object proc; 5609 volatile int len, volatile Lisp_Object object)
5641 unsigned char *volatile buf;
5642 volatile int len;
5643 volatile Lisp_Object object;
5644{ 5610{
5645 /* Use volatile to protect variables from being clobbered by longjmp. */ 5611 /* Use volatile to protect variables from being clobbered by longjmp. */
5646 struct Lisp_Process *p = XPROCESS (proc); 5612 struct Lisp_Process *p = XPROCESS (proc);
5647 int rv; 5613 int rv;
5648 struct coding_system *coding; 5614 struct coding_system *coding;
5649 struct gcpro gcpro1; 5615 struct gcpro gcpro1;
5650 SIGTYPE (*volatile old_sigpipe) (); 5616 SIGTYPE (*volatile old_sigpipe) (int);
5651 5617
5652 GCPRO1 (object); 5618 GCPRO1 (object);
5653 5619
@@ -5760,7 +5726,7 @@ send_process (proc, buf, len, object)
5760 while (this > 0) 5726 while (this > 0)
5761 { 5727 {
5762 int outfd = p->outfd; 5728 int outfd = p->outfd;
5763 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); 5729 old_sigpipe = (SIGTYPE (*) (int)) signal (SIGPIPE, send_process_trap);
5764#ifdef DATAGRAM_SOCKETS 5730#ifdef DATAGRAM_SOCKETS
5765 if (DATAGRAM_CHAN_P (outfd)) 5731 if (DATAGRAM_CHAN_P (outfd))
5766 { 5732 {
@@ -5927,8 +5893,7 @@ Output from processes can arrive in between bunches. */)
5927/* Return the foreground process group for the tty/pty that 5893/* Return the foreground process group for the tty/pty that
5928 the process P uses. */ 5894 the process P uses. */
5929static int 5895static int
5930emacs_get_tty_pgrp (p) 5896emacs_get_tty_pgrp (struct Lisp_Process *p)
5931 struct Lisp_Process *p;
5932{ 5897{
5933 int gid = -1; 5898 int gid = -1;
5934 5899
@@ -5997,11 +5962,8 @@ return t unconditionally. */)
5997 their uid, for which killpg would return an EPERM error. */ 5962 their uid, for which killpg would return an EPERM error. */
5998 5963
5999static void 5964static void
6000process_send_signal (process, signo, current_group, nomsg) 5965process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
6001 Lisp_Object process; 5966 int nomsg)
6002 int signo;
6003 Lisp_Object current_group;
6004 int nomsg;
6005{ 5967{
6006 Lisp_Object proc; 5968 Lisp_Object proc;
6007 register struct Lisp_Process *p; 5969 register struct Lisp_Process *p;
@@ -6381,7 +6343,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6381 CHECK_SYMBOL (sigcode); 6343 CHECK_SYMBOL (sigcode);
6382 name = SDATA (SYMBOL_NAME (sigcode)); 6344 name = SDATA (SYMBOL_NAME (sigcode));
6383 6345
6384 if (!strncmp(name, "SIG", 3) || !strncmp(name, "sig", 3)) 6346 if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
6385 name += 3; 6347 name += 3;
6386 6348
6387 if (0) 6349 if (0)
@@ -6555,11 +6517,11 @@ process has been transmitted to the serial port. */)
6555 if (!proc_encode_coding_system[new_outfd]) 6517 if (!proc_encode_coding_system[new_outfd])
6556 proc_encode_coding_system[new_outfd] 6518 proc_encode_coding_system[new_outfd]
6557 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); 6519 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
6558 bcopy (proc_encode_coding_system[old_outfd], 6520 memcpy (proc_encode_coding_system[new_outfd],
6559 proc_encode_coding_system[new_outfd], 6521 proc_encode_coding_system[old_outfd],
6560 sizeof (struct coding_system)); 6522 sizeof (struct coding_system));
6561 bzero (proc_encode_coding_system[old_outfd], 6523 memset (proc_encode_coding_system[old_outfd], 0,
6562 sizeof (struct coding_system)); 6524 sizeof (struct coding_system));
6563 6525
6564 XPROCESS (proc)->outfd = new_outfd; 6526 XPROCESS (proc)->outfd = new_outfd;
6565 } 6527 }
@@ -6570,8 +6532,7 @@ process has been transmitted to the serial port. */)
6570 If `buffer' is nil, kill all processes */ 6532 If `buffer' is nil, kill all processes */
6571 6533
6572void 6534void
6573kill_buffer_processes (buffer) 6535kill_buffer_processes (Lisp_Object buffer)
6574 Lisp_Object buffer;
6575{ 6536{
6576 Lisp_Object tail, proc; 6537 Lisp_Object tail, proc;
6577 6538
@@ -6616,8 +6577,7 @@ kill_buffer_processes (buffer)
6616 6577
6617#ifdef SIGCHLD 6578#ifdef SIGCHLD
6618SIGTYPE 6579SIGTYPE
6619sigchld_handler (signo) 6580sigchld_handler (int signo)
6620 int signo;
6621{ 6581{
6622 int old_errno = errno; 6582 int old_errno = errno;
6623 Lisp_Object proc; 6583 Lisp_Object proc;
@@ -6758,16 +6718,14 @@ sigchld_handler (signo)
6758 6718
6759 6719
6760static Lisp_Object 6720static Lisp_Object
6761exec_sentinel_unwind (data) 6721exec_sentinel_unwind (Lisp_Object data)
6762 Lisp_Object data;
6763{ 6722{
6764 XPROCESS (XCAR (data))->sentinel = XCDR (data); 6723 XPROCESS (XCAR (data))->sentinel = XCDR (data);
6765 return Qnil; 6724 return Qnil;
6766} 6725}
6767 6726
6768static Lisp_Object 6727static Lisp_Object
6769exec_sentinel_error_handler (error) 6728exec_sentinel_error_handler (Lisp_Object error)
6770 Lisp_Object error;
6771{ 6729{
6772 cmd_error_internal (error, "error in process sentinel: "); 6730 cmd_error_internal (error, "error in process sentinel: ");
6773 Vinhibit_quit = Qt; 6731 Vinhibit_quit = Qt;
@@ -6777,8 +6735,7 @@ exec_sentinel_error_handler (error)
6777} 6735}
6778 6736
6779static void 6737static void
6780exec_sentinel (proc, reason) 6738exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6781 Lisp_Object proc, reason;
6782{ 6739{
6783 Lisp_Object sentinel, obuffer, odeactivate, okeymap; 6740 Lisp_Object sentinel, obuffer, odeactivate, okeymap;
6784 register struct Lisp_Process *p = XPROCESS (proc); 6741 register struct Lisp_Process *p = XPROCESS (proc);
@@ -6863,8 +6820,7 @@ exec_sentinel (proc, reason)
6863 but can be done at other times. */ 6820 but can be done at other times. */
6864 6821
6865static void 6822static void
6866status_notify (deleting_process) 6823status_notify (struct Lisp_Process *deleting_process)
6867 struct Lisp_Process *deleting_process;
6868{ 6824{
6869 register Lisp_Object proc, buffer; 6825 register Lisp_Object proc, buffer;
6870 Lisp_Object tail, msg; 6826 Lisp_Object tail, msg;
@@ -7061,11 +7017,34 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
7061 7017
7062 7018
7063 7019
7020/* Stop reading input from keyboard sources. */
7021
7022void
7023hold_keyboard_input (void)
7024{
7025 kbd_is_on_hold = 1;
7026}
7027
7028/* Resume reading input from keyboard sources. */
7029
7030void
7031unhold_keyboard_input (void)
7032{
7033 kbd_is_on_hold = 0;
7034}
7035
7036/* Return non-zero if keyboard input is on hold, zero otherwise. */
7037
7038int
7039kbd_on_hold_p (void)
7040{
7041 return kbd_is_on_hold;
7042}
7043
7064/* Add DESC to the set of keyboard input descriptors. */ 7044/* Add DESC to the set of keyboard input descriptors. */
7065 7045
7066void 7046void
7067add_keyboard_wait_descriptor (desc) 7047add_keyboard_wait_descriptor (int desc)
7068 int desc;
7069{ 7048{
7070 FD_SET (desc, &input_wait_mask); 7049 FD_SET (desc, &input_wait_mask);
7071 FD_SET (desc, &non_process_wait_mask); 7050 FD_SET (desc, &non_process_wait_mask);
@@ -7076,8 +7055,7 @@ add_keyboard_wait_descriptor (desc)
7076static int add_gpm_wait_descriptor_called_flag; 7055static int add_gpm_wait_descriptor_called_flag;
7077 7056
7078void 7057void
7079add_gpm_wait_descriptor (desc) 7058add_gpm_wait_descriptor (int desc)
7080 int desc;
7081{ 7059{
7082 if (! add_gpm_wait_descriptor_called_flag) 7060 if (! add_gpm_wait_descriptor_called_flag)
7083 FD_CLR (0, &input_wait_mask); 7061 FD_CLR (0, &input_wait_mask);
@@ -7091,8 +7069,7 @@ add_gpm_wait_descriptor (desc)
7091/* From now on, do not expect DESC to give keyboard input. */ 7069/* From now on, do not expect DESC to give keyboard input. */
7092 7070
7093void 7071void
7094delete_keyboard_wait_descriptor (desc) 7072delete_keyboard_wait_descriptor (int desc)
7095 int desc;
7096{ 7073{
7097 int fd; 7074 int fd;
7098 int lim = max_keyboard_desc; 7075 int lim = max_keyboard_desc;
@@ -7109,8 +7086,7 @@ delete_keyboard_wait_descriptor (desc)
7109} 7086}
7110 7087
7111void 7088void
7112delete_gpm_wait_descriptor (desc) 7089delete_gpm_wait_descriptor (int desc)
7113 int desc;
7114{ 7090{
7115 int fd; 7091 int fd;
7116 int lim = max_gpm_desc; 7092 int lim = max_gpm_desc;
@@ -7130,8 +7106,7 @@ delete_gpm_wait_descriptor (desc)
7130 that corresponds to one of the keyboard input descriptors. */ 7106 that corresponds to one of the keyboard input descriptors. */
7131 7107
7132static int 7108static int
7133keyboard_bit_set (mask) 7109keyboard_bit_set (fd_set *mask)
7134 SELECT_TYPE *mask;
7135{ 7110{
7136 int fd; 7111 int fd;
7137 7112
@@ -7215,7 +7190,7 @@ integer or floating point values.
7215} 7190}
7216 7191
7217void 7192void
7218init_process () 7193init_process (void)
7219{ 7194{
7220 register int i; 7195 register int i;
7221 7196
@@ -7259,10 +7234,10 @@ init_process ()
7259 chan_process[i] = Qnil; 7234 chan_process[i] = Qnil;
7260 proc_buffered_char[i] = -1; 7235 proc_buffered_char[i] = -1;
7261 } 7236 }
7262 bzero (proc_decode_coding_system, sizeof proc_decode_coding_system); 7237 memset (proc_decode_coding_system, 0, sizeof proc_decode_coding_system);
7263 bzero (proc_encode_coding_system, sizeof proc_encode_coding_system); 7238 memset (proc_encode_coding_system, 0, sizeof proc_encode_coding_system);
7264#ifdef DATAGRAM_SOCKETS 7239#ifdef DATAGRAM_SOCKETS
7265 bzero (datagram_address, sizeof datagram_address); 7240 memset (datagram_address, 0, sizeof datagram_address);
7266#endif 7241#endif
7267 7242
7268#ifdef HAVE_SOCKETS 7243#ifdef HAVE_SOCKETS
@@ -7308,7 +7283,7 @@ init_process ()
7308 processes. As such, we only change the default value. */ 7283 processes. As such, we only change the default value. */
7309 if (initialized) 7284 if (initialized)
7310 { 7285 {
7311 char *release = get_operating_system_release(); 7286 char *release = get_operating_system_release ();
7312 if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION 7287 if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION
7313 && release[1] == '.')) { 7288 && release[1] == '.')) {
7314 Vprocess_connection_type = Qnil; 7289 Vprocess_connection_type = Qnil;
@@ -7318,7 +7293,7 @@ init_process ()
7318} 7293}
7319 7294
7320void 7295void
7321syms_of_process () 7296syms_of_process (void)
7322{ 7297{
7323 Qprocessp = intern_c_string ("processp"); 7298 Qprocessp = intern_c_string ("processp");
7324 staticpro (&Qprocessp); 7299 staticpro (&Qprocessp);
@@ -7957,6 +7932,7 @@ integer or floating point values.
7957void 7932void
7958init_process () 7933init_process ()
7959{ 7934{
7935 kbd_is_on_hold = 0;
7960} 7936}
7961 7937
7962void 7938void