comparison src/process.c @ 49600:23a1cea22d13

Trailing whitespace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 14:56:31 +0000
parents f9e4999d3025
children cbec1327e2f1
comparison
equal deleted inserted replaced
49599:5ade352e8d1c 49600:23a1cea22d13
99 #endif 99 #endif
100 100
101 #ifdef IRIS 101 #ifdef IRIS
102 #include <sys/sysmacros.h> /* for "minor" */ 102 #include <sys/sysmacros.h> /* for "minor" */
103 #endif /* not IRIS */ 103 #endif /* not IRIS */
104 104
105 #ifdef HAVE_SYS_WAIT 105 #ifdef HAVE_SYS_WAIT
106 #include <sys/wait.h> 106 #include <sys/wait.h>
107 #endif 107 #endif
108 108
109 #include "systime.h" 109 #include "systime.h"
355 p->status = status_convert (u.wt); 355 p->status = status_convert (u.wt);
356 p->raw_status_low = Qnil; 356 p->raw_status_low = Qnil;
357 p->raw_status_high = Qnil; 357 p->raw_status_high = Qnil;
358 } 358 }
359 359
360 /* Convert a process status word in Unix format to 360 /* Convert a process status word in Unix format to
361 the list that we use internally. */ 361 the list that we use internally. */
362 362
363 Lisp_Object 363 Lisp_Object
364 status_convert (w) 364 status_convert (w)
365 WAITTYPE w; 365 WAITTYPE w;
404 } 404 }
405 } 405 }
406 406
407 /* Return a string describing a process status list. */ 407 /* Return a string describing a process status list. */
408 408
409 Lisp_Object 409 Lisp_Object
410 status_message (status) 410 status_message (status)
411 Lisp_Object status; 411 Lisp_Object status;
412 { 412 {
413 Lisp_Object symbol; 413 Lisp_Object symbol;
414 int code, coredump; 414 int code, coredump;
683 } 683 }
684 else if (XINT (XPROCESS (process)->infd) >= 0) 684 else if (XINT (XPROCESS (process)->infd) >= 0)
685 { 685 {
686 Fkill_process (process, Qnil); 686 Fkill_process (process, Qnil);
687 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 687 /* Do this now, since remove_process will make sigchld_handler do nothing. */
688 XPROCESS (process)->status 688 XPROCESS (process)->status
689 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); 689 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil));
690 XSETINT (XPROCESS (process)->tick, ++process_tick); 690 XSETINT (XPROCESS (process)->tick, ++process_tick);
691 status_notify (); 691 status_notify ();
692 } 692 }
693 remove_process (process); 693 remove_process (process);
845 doc: /* Give PROCESS the filter function FILTER; nil means no filter. 845 doc: /* Give PROCESS the filter function FILTER; nil means no filter.
846 t means stop accepting output from the process. 846 t means stop accepting output from the process.
847 847
848 When a process has a filter, its buffer is not used for output. 848 When a process has a filter, its buffer is not used for output.
849 Instead, each time it does output, the entire string of output is 849 Instead, each time it does output, the entire string of output is
850 passed to the filter. 850 passed to the filter.
851 851
852 The filter gets two arguments: the process and the string of output. 852 The filter gets two arguments: the process and the string of output.
853 The string argument is normally a multibyte string, except: 853 The string argument is normally a multibyte string, except:
854 - if the process' input coding system is no-conversion or raw-text, 854 - if the process' input coding system is no-conversion or raw-text,
855 it is a unibyte string (the non-converted input), or else 855 it is a unibyte string (the non-converted input), or else
858 string to unibyte with `string-make-unibyte'). */) 858 string to unibyte with `string-make-unibyte'). */)
859 (process, filter) 859 (process, filter)
860 register Lisp_Object process, filter; 860 register Lisp_Object process, filter;
861 { 861 {
862 struct Lisp_Process *p; 862 struct Lisp_Process *p;
863 863
864 CHECK_PROCESS (process); 864 CHECK_PROCESS (process);
865 p = XPROCESS (process); 865 p = XPROCESS (process);
866 866
867 /* Don't signal an error if the process' input file descriptor 867 /* Don't signal an error if the process' input file descriptor
868 is closed. This could make debugging Lisp more difficult, 868 is closed. This could make debugging Lisp more difficult,
869 for example when doing something like 869 for example when doing something like
870 870
871 (setq process (start-process ...)) 871 (setq process (start-process ...))
872 (debug) 872 (debug)
873 (set-process-filter process ...) */ 873 (set-process-filter process ...) */
874 874
875 if (XINT (p->infd) >= 0) 875 if (XINT (p->infd) >= 0)
876 { 876 {
877 if (EQ (filter, Qt) && !EQ (p->status, Qlisten)) 877 if (EQ (filter, Qt) && !EQ (p->status, Qlisten))
878 { 878 {
879 FD_CLR (XINT (p->infd), &input_wait_mask); 879 FD_CLR (XINT (p->infd), &input_wait_mask);
884 { 884 {
885 FD_SET (XINT (p->infd), &input_wait_mask); 885 FD_SET (XINT (p->infd), &input_wait_mask);
886 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 886 FD_SET (XINT (p->infd), &non_keyboard_wait_mask);
887 } 887 }
888 } 888 }
889 889
890 p->filter = filter; 890 p->filter = filter;
891 if (NETCONN1_P (p)) 891 if (NETCONN1_P (p))
892 p->childp = Fplist_put (p->childp, QCfilter, filter); 892 p->childp = Fplist_put (p->childp, QCfilter, filter);
893 return filter; 893 return filter;
894 } 894 }
935 register Lisp_Object process, height, width; 935 register Lisp_Object process, height, width;
936 { 936 {
937 CHECK_PROCESS (process); 937 CHECK_PROCESS (process);
938 CHECK_NATNUM (height); 938 CHECK_NATNUM (height);
939 CHECK_NATNUM (width); 939 CHECK_NATNUM (width);
940 940
941 if (XINT (XPROCESS (process)->infd) < 0 941 if (XINT (XPROCESS (process)->infd) < 0
942 || set_window_size (XINT (XPROCESS (process)->infd), 942 || set_window_size (XINT (XPROCESS (process)->infd),
943 XINT (height), XINT (width)) <= 0) 943 XINT (height), XINT (width)) <= 0)
944 return Qnil; 944 return Qnil;
945 else 945 else
1031 contact = XPROCESS (process)->childp; 1031 contact = XPROCESS (process)->childp;
1032 1032
1033 #ifdef DATAGRAM_SOCKETS 1033 #ifdef DATAGRAM_SOCKETS
1034 if (DATAGRAM_CONN_P (process) 1034 if (DATAGRAM_CONN_P (process)
1035 && (EQ (key, Qt) || EQ (key, QCremote))) 1035 && (EQ (key, Qt) || EQ (key, QCremote)))
1036 contact = Fplist_put (contact, QCremote, 1036 contact = Fplist_put (contact, QCremote,
1037 Fprocess_datagram_address (process)); 1037 Fprocess_datagram_address (process));
1038 #endif 1038 #endif
1039 1039
1040 if (!NETCONN_P (process) || EQ (key, Qt)) 1040 if (!NETCONN_P (process) || EQ (key, Qt))
1041 return contact; 1041 return contact;
1125 { 1125 {
1126 Lisp_Object args[2]; 1126 Lisp_Object args[2];
1127 args[0] = build_string ("<Family %d>"); 1127 args[0] = build_string ("<Family %d>");
1128 args[1] = Fcar (address); 1128 args[1] = Fcar (address);
1129 return Fformat (2, args); 1129 return Fformat (2, args);
1130 1130
1131 } 1131 }
1132 1132
1133 return Qnil; 1133 return Qnil;
1134 } 1134 }
1135 #endif 1135 #endif
1230 update_status (p); 1230 update_status (p);
1231 symbol = p->status; 1231 symbol = p->status;
1232 if (CONSP (p->status)) 1232 if (CONSP (p->status))
1233 symbol = XCAR (p->status); 1233 symbol = XCAR (p->status);
1234 1234
1235 1235
1236 if (EQ (symbol, Qsignal)) 1236 if (EQ (symbol, Qsignal))
1237 { 1237 {
1238 Lisp_Object tem; 1238 Lisp_Object tem;
1239 tem = Fcar (Fcdr (p->status)); 1239 tem = Fcar (Fcdr (p->status));
1240 #ifdef VMS 1240 #ifdef VMS
1317 sprintf (tembuf, "(network %s connection to %s)\n", 1317 sprintf (tembuf, "(network %s connection to %s)\n",
1318 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1318 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"),
1319 (STRINGP (host) ? (char *)SDATA (host) : "?")); 1319 (STRINGP (host) ? (char *)SDATA (host) : "?"));
1320 insert_string (tembuf); 1320 insert_string (tembuf);
1321 } 1321 }
1322 else 1322 else
1323 { 1323 {
1324 tem = p->command; 1324 tem = p->command;
1325 while (1) 1325 while (1)
1326 { 1326 {
1327 tem1 = Fcar (tem); 1327 tem1 = Fcar (tem);
1406 1406
1407 current_dir = current_buffer->directory; 1407 current_dir = current_buffer->directory;
1408 1408
1409 GCPRO2 (buffer, current_dir); 1409 GCPRO2 (buffer, current_dir);
1410 1410
1411 current_dir 1411 current_dir
1412 = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), 1412 = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir),
1413 Qnil); 1413 Qnil);
1414 if (NILP (Ffile_accessible_directory_p (current_dir))) 1414 if (NILP (Ffile_accessible_directory_p (current_dir)))
1415 report_file_error ("Setting current directory", 1415 report_file_error ("Setting current directory",
1416 Fcons (current_buffer->directory, Qnil)); 1416 Fcons (current_buffer->directory, Qnil));
1510 CHECK_STRING (tem); 1510 CHECK_STRING (tem);
1511 strcat (new_argv, " "); 1511 strcat (new_argv, " ");
1512 strcat (new_argv, SDATA (tem)); 1512 strcat (new_argv, SDATA (tem));
1513 } 1513 }
1514 /* Need to add code here to check for program existence on VMS */ 1514 /* Need to add code here to check for program existence on VMS */
1515 1515
1516 #else /* not VMS */ 1516 #else /* not VMS */
1517 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); 1517 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
1518 1518
1519 /* If program file name is not absolute, search our path for it. 1519 /* If program file name is not absolute, search our path for it.
1520 Put the name we will really use in TEM. */ 1520 Put the name we will really use in TEM. */
1807 it might cause call-process to hang and subsequent asynchronous 1807 it might cause call-process to hang and subsequent asynchronous
1808 processes to get their return values scrambled. */ 1808 processes to get their return values scrambled. */
1809 XSETINT (XPROCESS (process)->pid, -1); 1809 XSETINT (XPROCESS (process)->pid, -1);
1810 1810
1811 BLOCK_INPUT; 1811 BLOCK_INPUT;
1812 1812
1813 { 1813 {
1814 /* child_setup must clobber environ on systems with true vfork. 1814 /* child_setup must clobber environ on systems with true vfork.
1815 Protect it from permanent change. */ 1815 Protect it from permanent change. */
1816 char **save_environ = environ; 1816 char **save_environ = environ;
1817 1817
1872 int ldisc = NTTYDISC; 1872 int ldisc = NTTYDISC;
1873 ioctl (xforkin, TIOCSETD, &ldisc); 1873 ioctl (xforkin, TIOCSETD, &ldisc);
1874 } 1874 }
1875 #endif 1875 #endif
1876 #endif 1876 #endif
1877 #ifdef TIOCNOTTY 1877 #ifdef TIOCNOTTY
1878 /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you 1878 /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you
1879 can do TIOCSPGRP only to the process's controlling tty. */ 1879 can do TIOCSPGRP only to the process's controlling tty. */
1880 if (pty_flag) 1880 if (pty_flag)
1881 { 1881 {
1882 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? 1882 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here?
1883 I can't test it since I don't have 4.3. */ 1883 I can't test it since I don't have 4.3. */
1884 int j = emacs_open ("/dev/tty", O_RDWR, 0); 1884 int j = emacs_open ("/dev/tty", O_RDWR, 0);
1885 ioctl (j, TIOCNOTTY, 0); 1885 ioctl (j, TIOCNOTTY, 0);
1886 emacs_close (j); 1886 emacs_close (j);
1887 #ifndef USG 1887 #ifndef USG
1972 if (pty_flag) 1972 if (pty_flag)
1973 child_setup_tty (xforkout); 1973 child_setup_tty (xforkout);
1974 #ifdef WINDOWSNT 1974 #ifdef WINDOWSNT
1975 pid = child_setup (xforkin, xforkout, xforkout, 1975 pid = child_setup (xforkin, xforkout, xforkout,
1976 new_argv, 1, current_dir); 1976 new_argv, 1, current_dir);
1977 #else /* not WINDOWSNT */ 1977 #else /* not WINDOWSNT */
1978 child_setup (xforkin, xforkout, xforkout, 1978 child_setup (xforkin, xforkout, xforkout,
1979 new_argv, 1, current_dir); 1979 new_argv, 1, current_dir);
1980 #endif /* not WINDOWSNT */ 1980 #endif /* not WINDOWSNT */
1981 } 1981 }
1982 environ = save_environ; 1982 environ = save_environ;
2005 this close hangs. I don't know why. 2005 this close hangs. I don't know why.
2006 So have an interrupt jar it loose. */ 2006 So have an interrupt jar it loose. */
2007 { 2007 {
2008 struct atimer *timer; 2008 struct atimer *timer;
2009 EMACS_TIME offset; 2009 EMACS_TIME offset;
2010 2010
2011 stop_polling (); 2011 stop_polling ();
2012 EMACS_SET_SECS_USECS (offset, 1, 0); 2012 EMACS_SET_SECS_USECS (offset, 1, 0);
2013 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); 2013 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0);
2014 2014
2015 XPROCESS (process)->subtty = Qnil; 2015 XPROCESS (process)->subtty = Qnil;
2016 if (forkin >= 0) 2016 if (forkin >= 0)
2017 emacs_close (forkin); 2017 emacs_close (forkin);
2018 2018
2019 cancel_atimer (timer); 2019 cancel_atimer (timer);
2020 start_polling (); 2020 start_polling ();
2021 } 2021 }
2022 2022
2023 if (forkin != forkout && forkout >= 0) 2023 if (forkin != forkout && forkout >= 0)
2024 emacs_close (forkout); 2024 emacs_close (forkout);
2025 2025
2026 #ifdef HAVE_PTYS 2026 #ifdef HAVE_PTYS
2027 if (pty_flag) 2027 if (pty_flag)
2258 #endif 2258 #endif
2259 2259
2260 2260
2261 static struct socket_options { 2261 static struct socket_options {
2262 /* The name of this option. Should be lowercase version of option 2262 /* The name of this option. Should be lowercase version of option
2263 name without SO_ prefix. */ 2263 name without SO_ prefix. */
2264 char *name; 2264 char *name;
2265 /* Length of name. */ 2265 /* Length of name. */
2266 int nlen; 2266 int nlen;
2267 /* Option level SOL_... */ 2267 /* Option level SOL_... */
2268 int optlevel; 2268 int optlevel;
2404 arg = ""; 2404 arg = "";
2405 else if (STRINGP (val)) 2405 else if (STRINGP (val))
2406 arg = (char *) SDATA (val); 2406 arg = (char *) SDATA (val);
2407 else if (XSYMBOL (val)) 2407 else if (XSYMBOL (val))
2408 arg = (char *) SDATA (SYMBOL_NAME (val)); 2408 arg = (char *) SDATA (SYMBOL_NAME (val));
2409 else 2409 else
2410 error ("Invalid argument to %s option", name); 2410 error ("Invalid argument to %s option", name);
2411 } 2411 }
2412 ret = setsockopt (s, sopt->optlevel, sopt->optnum, 2412 ret = setsockopt (s, sopt->optlevel, sopt->optnum,
2413 arg, strlen (arg)); 2413 arg, strlen (arg));
2414 } 2414 }
2415 2415
2416 #ifdef SO_LINGER 2416 #ifdef SO_LINGER
2417 case SOPT_LINGER: 2417 case SOPT_LINGER:
2418 { 2418 {
2419 struct linger linger; 2419 struct linger linger;
2420 2420
2421 linger.l_onoff = 1; 2421 linger.l_onoff = 1;
2453 return 1; 2453 return 1;
2454 } 2454 }
2455 2455
2456 DEFUN ("set-network-process-options", 2456 DEFUN ("set-network-process-options",
2457 Fset_network_process_options, Sset_network_process_options, 2457 Fset_network_process_options, Sset_network_process_options,
2458 1, MANY, 0, 2458 1, MANY, 0,
2459 doc: /* Set one or more options for network process PROCESS. 2459 doc: /* Set one or more options for network process PROCESS.
2460 Each option is either a string "OPT=VALUE" or a cons (OPT . VALUE). 2460 Each option is either a string "OPT=VALUE" or a cons (OPT . VALUE).
2461 A boolean value is false if it either zero or nil, true otherwise. 2461 A boolean value is false if it either zero or nil, true otherwise.
2462 2462
2463 The following options are known. Consult the relevant system manual 2463 The following options are known. Consult the relevant system manual
2464 pages for more information. 2464 pages for more information.
2465 2465
2466 bindtodevice=NAME -- bind to interface NAME, or remove binding if nil. 2466 bindtodevice=NAME -- bind to interface NAME, or remove binding if nil.
2467 broadcast=BOOL -- Allow send and receive of datagram broadcasts. 2467 broadcast=BOOL -- Allow send and receive of datagram broadcasts.
2468 dontroute=BOOL -- Only send to directly connected hosts. 2468 dontroute=BOOL -- Only send to directly connected hosts.
2469 keepalive=BOOL -- Send keep-alive messages on network stream. 2469 keepalive=BOOL -- Send keep-alive messages on network stream.
2470 linger=BOOL or TIMEOUT -- Send queued messages before closing. 2470 linger=BOOL or TIMEOUT -- Send queued messages before closing.
2471 oobinline=BOOL -- Place out-of-band data in receive data stream. 2471 oobinline=BOOL -- Place out-of-band data in receive data stream.
2472 priority=INT -- Set protocol defined priority for sent packets. 2472 priority=INT -- Set protocol defined priority for sent packets.
2473 reuseaddr=BOOL -- Allow reusing a recently used address. 2473 reuseaddr=BOOL -- Allow reusing a recently used address.
2474 2474
2475 usage: (set-network-process-options PROCESS &rest OPTIONS) */) 2475 usage: (set-network-process-options PROCESS &rest OPTIONS) */)
2476 (nargs, args) 2476 (nargs, args)
2505 exactly like a normal process when reading and writing. Primary 2505 exactly like a normal process when reading and writing. Primary
2506 differences are in status display and process deletion. A network 2506 differences are in status display and process deletion. A network
2507 connection has no PID; you cannot signal it. All you can do is 2507 connection has no PID; you cannot signal it. All you can do is
2508 stop/continue it and deactivate/close it via delete-process */ 2508 stop/continue it and deactivate/close it via delete-process */
2509 2509
2510 DEFUN ("make-network-process", Fmake_network_process, Smake_network_process, 2510 DEFUN ("make-network-process", Fmake_network_process, Smake_network_process,
2511 0, MANY, 0, 2511 0, MANY, 0,
2512 doc: /* Create and return a network server or client process. 2512 doc: /* Create and return a network server or client process.
2513 2513
2514 In Emacs, network connections are represented by process objects, so 2514 In Emacs, network connections are represented by process objects, so
2515 input and output work as for subprocesses and `delete-process' closes 2515 input and output work as for subprocesses and `delete-process' closes
2516 a network connection. However, a network process has no process id, 2516 a network connection. However, a network process has no process id,
2597 client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER 2597 client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER
2598 is the server process, CLIENT is the new process for the connection, 2598 is the server process, CLIENT is the new process for the connection,
2599 and MESSAGE is a string. 2599 and MESSAGE is a string.
2600 2600
2601 :plist PLIST -- Install PLIST as the new process' initial plist. 2601 :plist PLIST -- Install PLIST as the new process' initial plist.
2602 2602
2603 :server BOOL -- if BOOL is non-nil, create a server process for the 2603 :server BOOL -- if BOOL is non-nil, create a server process for the
2604 specified FAMILY, SERVICE, and connection type (stream or datagram). 2604 specified FAMILY, SERVICE, and connection type (stream or datagram).
2605 Default is a client process. 2605 Default is a client process.
2606 2606
2607 A server process will listen for and accept connections from 2607 A server process will listen for and accept connections from
2608 clients. When a client connection is accepted, a new network process 2608 clients. When a client connection is accepted, a new network process
2609 is created for the connection with the following parameters: 2609 is created for the connection with the following parameters:
2610 - The client's process name is constructed by concatenating the server 2610 - The client's process name is constructed by concatenating the server
2611 process' NAME and a client identification string. 2611 process' NAME and a client identification string.
2612 - If the FILTER argument is non-nil, the client process will not get a 2612 - If the FILTER argument is non-nil, the client process will not get a
2613 separate process buffer; otherwise, the client's process buffer is a newly 2613 separate process buffer; otherwise, the client's process buffer is a newly
2614 created buffer named after the server process' BUFFER name or process 2614 created buffer named after the server process' BUFFER name or process
2615 NAME concatenated with the client identification string. 2615 NAME concatenated with the client identification string.
2616 - The connection type and the process filter and sentinel parameters are 2616 - The connection type and the process filter and sentinel parameters are
2617 inherited from the server process' TYPE, FILTER and SENTINEL. 2617 inherited from the server process' TYPE, FILTER and SENTINEL.
2618 - The client process' contact info is set according to the client's 2618 - The client process' contact info is set according to the client's
2619 addressing information (typically an IP address and a port number). 2619 addressing information (typically an IP address and a port number).
2620 - The client process' plist is initialized from the server's plist. 2620 - The client process' plist is initialized from the server's plist.
2730 2730
2731 #ifdef TERM 2731 #ifdef TERM
2732 /* Let's handle TERM before things get complicated ... */ 2732 /* Let's handle TERM before things get complicated ... */
2733 host = Fplist_get (contact, QChost); 2733 host = Fplist_get (contact, QChost);
2734 CHECK_STRING (host); 2734 CHECK_STRING (host);
2735 2735
2736 service = Fplist_get (contact, QCservice); 2736 service = Fplist_get (contact, QCservice);
2737 if (INTEGERP (service)) 2737 if (INTEGERP (service))
2738 port = htons ((unsigned short) XINT (service)); 2738 port = htons ((unsigned short) XINT (service));
2739 else 2739 else
2740 { 2740 {
2879 port = htons ((unsigned short) XINT (service)); 2879 port = htons ((unsigned short) XINT (service));
2880 else 2880 else
2881 { 2881 {
2882 struct servent *svc_info; 2882 struct servent *svc_info;
2883 CHECK_STRING (service); 2883 CHECK_STRING (service);
2884 svc_info = getservbyname (SDATA (service), 2884 svc_info = getservbyname (SDATA (service),
2885 (socktype == SOCK_DGRAM ? "udp" : "tcp")); 2885 (socktype == SOCK_DGRAM ? "udp" : "tcp"));
2886 if (svc_info == 0) 2886 if (svc_info == 0)
2887 error ("Unknown service: %s", SDATA (service)); 2887 error ("Unknown service: %s", SDATA (service));
2888 port = svc_info->s_port; 2888 port = svc_info->s_port;
2889 } 2889 }
2902 as it may `hang' emacs for a very long time. */ 2902 as it may `hang' emacs for a very long time. */
2903 immediate_quit = 1; 2903 immediate_quit = 1;
2904 QUIT; 2904 QUIT;
2905 host_info_ptr = gethostbyname (SDATA (host)); 2905 host_info_ptr = gethostbyname (SDATA (host));
2906 immediate_quit = 0; 2906 immediate_quit = 0;
2907 2907
2908 if (host_info_ptr) 2908 if (host_info_ptr)
2909 { 2909 {
2910 bcopy (host_info_ptr->h_addr, (char *) &address_in.sin_addr, 2910 bcopy (host_info_ptr->h_addr, (char *) &address_in.sin_addr,
2911 host_info_ptr->h_length); 2911 host_info_ptr->h_length);
2912 family = host_info_ptr->h_addrtype; 2912 family = host_info_ptr->h_addrtype;
2983 s = -1; 2983 s = -1;
2984 continue; 2984 continue;
2985 } 2985 }
2986 } 2986 }
2987 #endif 2987 #endif
2988 2988
2989 /* Make us close S if quit. */ 2989 /* Make us close S if quit. */
2990 record_unwind_protect (close_file_unwind, make_number (s)); 2990 record_unwind_protect (close_file_unwind, make_number (s));
2991 2991
2992 if (is_server) 2992 if (is_server)
2993 { 2993 {
2998 { 2998 {
2999 int optval = 1; 2999 int optval = 1;
3000 if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval)) 3000 if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval))
3001 report_file_error ("Cannot set reuse option on server socket.", Qnil); 3001 report_file_error ("Cannot set reuse option on server socket.", Qnil);
3002 } 3002 }
3003 3003
3004 if (bind (s, lres->ai_addr, lres->ai_addrlen)) 3004 if (bind (s, lres->ai_addr, lres->ai_addrlen))
3005 report_file_error ("Cannot bind server socket", Qnil); 3005 report_file_error ("Cannot bind server socket", Qnil);
3006 3006
3007 #ifdef HAVE_GETSOCKNAME 3007 #ifdef HAVE_GETSOCKNAME
3008 if (EQ (service, Qt)) 3008 if (EQ (service, Qt))
3033 bind_polling_period call above doesn't always turn all the 3033 bind_polling_period call above doesn't always turn all the
3034 short-interval ones off, especially if interrupt_input is 3034 short-interval ones off, especially if interrupt_input is
3035 set. 3035 set.
3036 3036
3037 It'd be nice to be able to control the connect timeout 3037 It'd be nice to be able to control the connect timeout
3038 though. Would non-blocking connect calls be portable? 3038 though. Would non-blocking connect calls be portable?
3039 3039
3040 This used to be conditioned by HAVE_GETADDRINFO. Why? */ 3040 This used to be conditioned by HAVE_GETADDRINFO. Why? */
3041 3041
3042 turn_on_atimers (0); 3042 turn_on_atimers (0);
3043 3043
3109 } 3109 }
3110 else 3110 else
3111 bcopy (lres->ai_addr, datagram_address[s].sa, lres->ai_addrlen); 3111 bcopy (lres->ai_addr, datagram_address[s].sa, lres->ai_addrlen);
3112 } 3112 }
3113 #endif 3113 #endif
3114 contact = Fplist_put (contact, QCaddress, 3114 contact = Fplist_put (contact, QCaddress,
3115 conv_sockaddr_to_lisp (lres->ai_addr, lres->ai_addrlen)); 3115 conv_sockaddr_to_lisp (lres->ai_addr, lres->ai_addrlen));
3116 #ifdef HAVE_GETSOCKNAME 3116 #ifdef HAVE_GETSOCKNAME
3117 if (!is_server) 3117 if (!is_server)
3118 { 3118 {
3119 struct sockaddr_in sa1; 3119 struct sockaddr_in sa1;
3179 3179
3180 p = XPROCESS (proc); 3180 p = XPROCESS (proc);
3181 3181
3182 p->childp = contact; 3182 p->childp = contact;
3183 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); 3183 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist));
3184 3184
3185 p->buffer = buffer; 3185 p->buffer = buffer;
3186 p->sentinel = sentinel; 3186 p->sentinel = sentinel;
3187 p->filter = filter; 3187 p->filter = filter;
3188 p->log = Fplist_get (contact, QClog); 3188 p->log = Fplist_get (contact, QClog);
3189 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 3189 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3601 contact = Fcopy_sequence (ps->childp); 3601 contact = Fcopy_sequence (ps->childp);
3602 contact = Fplist_put (contact, QCserver, Qnil); 3602 contact = Fplist_put (contact, QCserver, Qnil);
3603 contact = Fplist_put (contact, QChost, host); 3603 contact = Fplist_put (contact, QChost, host);
3604 if (!NILP (service)) 3604 if (!NILP (service))
3605 contact = Fplist_put (contact, QCservice, service); 3605 contact = Fplist_put (contact, QCservice, service);
3606 contact = Fplist_put (contact, QCremote, 3606 contact = Fplist_put (contact, QCremote,
3607 conv_sockaddr_to_lisp (&saddr.sa, len)); 3607 conv_sockaddr_to_lisp (&saddr.sa, len));
3608 #ifdef HAVE_GETSOCKNAME 3608 #ifdef HAVE_GETSOCKNAME
3609 len = sizeof saddr; 3609 len = sizeof saddr;
3610 if (getsockname (s, &saddr.sa, &len) == 0) 3610 if (getsockname (s, &saddr.sa, &len) == 0)
3611 contact = Fplist_put (contact, QClocal, 3611 contact = Fplist_put (contact, QClocal,
3612 conv_sockaddr_to_lisp (&saddr.sa, len)); 3612 conv_sockaddr_to_lisp (&saddr.sa, len));
3613 #endif 3613 #endif
3614 3614
3615 p->childp = contact; 3615 p->childp = contact;
3616 p->plist = Fcopy_sequence (ps->plist); 3616 p->plist = Fcopy_sequence (ps->plist);
3632 } 3632 }
3633 3633
3634 if (s > max_process_desc) 3634 if (s > max_process_desc)
3635 max_process_desc = s; 3635 max_process_desc = s;
3636 3636
3637 /* Setup coding system for new process based on server process. 3637 /* Setup coding system for new process based on server process.
3638 This seems to be the proper thing to do, as the coding system 3638 This seems to be the proper thing to do, as the coding system
3639 of the new process should reflect the settings at the time the 3639 of the new process should reflect the settings at the time the
3640 server socket was opened; not the current settings. */ 3640 server socket was opened; not the current settings. */
3641 3641
3642 p->decode_coding_system = ps->decode_coding_system; 3642 p->decode_coding_system = ps->decode_coding_system;
3666 concat3 (build_string ("accept from "), 3666 concat3 (build_string ("accept from "),
3667 (STRINGP (host) ? host : build_string ("-")), 3667 (STRINGP (host) ? host : build_string ("-")),
3668 build_string ("\n"))); 3668 build_string ("\n")));
3669 3669
3670 if (!NILP (p->sentinel)) 3670 if (!NILP (p->sentinel))
3671 exec_sentinel (proc, 3671 exec_sentinel (proc,
3672 concat3 (build_string ("open from "), 3672 concat3 (build_string ("open from "),
3673 (STRINGP (host) ? host : build_string ("-")), 3673 (STRINGP (host) ? host : build_string ("-")),
3674 build_string ("\n"))); 3674 build_string ("\n")));
3675 } 3675 }
3676 3676
3829 3829
3830 do 3830 do
3831 { 3831 {
3832 int old_timers_run = timers_run; 3832 int old_timers_run = timers_run;
3833 struct buffer *old_buffer = current_buffer; 3833 struct buffer *old_buffer = current_buffer;
3834 3834
3835 timer_delay = timer_check (1); 3835 timer_delay = timer_check (1);
3836 3836
3837 /* If a timer has run, this might have changed buffers 3837 /* If a timer has run, this might have changed buffers
3838 an alike. Make read_key_sequence aware of that. */ 3838 an alike. Make read_key_sequence aware of that. */
3839 if (timers_run != old_timers_run 3839 if (timers_run != old_timers_run
3840 && old_buffer != current_buffer 3840 && old_buffer != current_buffer
3841 && waiting_for_user_input_p == -1) 3841 && waiting_for_user_input_p == -1)
3842 record_asynch_buffer_change (); 3842 record_asynch_buffer_change ();
3843 3843
3844 if (timers_run != old_timers_run && do_display) 3844 if (timers_run != old_timers_run && do_display)
3845 /* We must retry, since a timer may have requeued itself 3845 /* We must retry, since a timer may have requeued itself
3846 and that could alter the time_delay. */ 3846 and that could alter the time_delay. */
3847 redisplay_preserve_echo_area (9); 3847 redisplay_preserve_echo_area (9);
3848 else 3848 else
3900 FD_CLR (0, &Atemp); 3900 FD_CLR (0, &Atemp);
3901 #endif 3901 #endif
3902 Ctemp = connect_wait_mask; 3902 Ctemp = connect_wait_mask;
3903 EMACS_SET_SECS_USECS (timeout, 0, 0); 3903 EMACS_SET_SECS_USECS (timeout, 0, 0);
3904 if ((select (max (max_process_desc, max_keyboard_desc) + 1, 3904 if ((select (max (max_process_desc, max_keyboard_desc) + 1,
3905 &Atemp, 3905 &Atemp,
3906 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), 3906 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
3907 (SELECT_TYPE *)0, &timeout) 3907 (SELECT_TYPE *)0, &timeout)
3908 <= 0)) 3908 <= 0))
3909 { 3909 {
3910 /* It's okay for us to do this and then continue with 3910 /* It's okay for us to do this and then continue with
3933 nread = read_process_output (proc, XINT (wait_proc->infd)); 3933 nread = read_process_output (proc, XINT (wait_proc->infd));
3934 3934
3935 if (nread == 0) 3935 if (nread == 0)
3936 break; 3936 break;
3937 3937
3938 if (0 < nread) 3938 if (0 < nread)
3939 total_nread += nread; 3939 total_nread += nread;
3940 #ifdef EIO 3940 #ifdef EIO
3941 else if (nread == -1 && EIO == errno) 3941 else if (nread == -1 && EIO == errno)
3942 break; 3942 break;
3943 #endif 3943 #endif
3994 else 3994 else
3995 { 3995 {
3996 if (check_connect) 3996 if (check_connect)
3997 Connecting = connect_wait_mask; 3997 Connecting = connect_wait_mask;
3998 nfds = select (max (max_process_desc, max_keyboard_desc) + 1, 3998 nfds = select (max (max_process_desc, max_keyboard_desc) + 1,
3999 &Available, 3999 &Available,
4000 (check_connect ? &Connecting : (SELECT_TYPE *)0), 4000 (check_connect ? &Connecting : (SELECT_TYPE *)0),
4001 (SELECT_TYPE *)0, &timeout); 4001 (SELECT_TYPE *)0, &timeout);
4002 } 4002 }
4003 4003
4004 xerrno = errno; 4004 xerrno = errno;
4091 if (XINT (read_kbd) != 0) 4091 if (XINT (read_kbd) != 0)
4092 { 4092 {
4093 int old_timers_run = timers_run; 4093 int old_timers_run = timers_run;
4094 struct buffer *old_buffer = current_buffer; 4094 struct buffer *old_buffer = current_buffer;
4095 int leave = 0; 4095 int leave = 0;
4096 4096
4097 if (detect_input_pending_run_timers (do_display)) 4097 if (detect_input_pending_run_timers (do_display))
4098 { 4098 {
4099 swallow_events (do_display); 4099 swallow_events (do_display);
4100 if (detect_input_pending_run_timers (do_display)) 4100 if (detect_input_pending_run_timers (do_display))
4101 leave = 1; 4101 leave = 1;
4108 && old_buffer != current_buffer) 4108 && old_buffer != current_buffer)
4109 record_asynch_buffer_change (); 4109 record_asynch_buffer_change ();
4110 4110
4111 if (leave) 4111 if (leave)
4112 break; 4112 break;
4113 } 4113 }
4114 4114
4115 /* If there is unread keyboard input, also return. */ 4115 /* If there is unread keyboard input, also return. */
4116 if (XINT (read_kbd) != 0 4116 if (XINT (read_kbd) != 0
4117 && requeued_events_pending_p ()) 4117 && requeued_events_pending_p ())
4118 break; 4118 break;
4119 4119
4256 if (EQ (XPROCESS (proc)->status, Qrun)) 4256 if (EQ (XPROCESS (proc)->status, Qrun))
4257 XPROCESS (proc)->status 4257 XPROCESS (proc)->status
4258 = Fcons (Qexit, Fcons (make_number (256), Qnil)); 4258 = Fcons (Qexit, Fcons (make_number (256), Qnil));
4259 } 4259 }
4260 } 4260 }
4261 #ifdef NON_BLOCKING_CONNECT 4261 #ifdef NON_BLOCKING_CONNECT
4262 if (check_connect && FD_ISSET (channel, &Connecting)) 4262 if (check_connect && FD_ISSET (channel, &Connecting))
4263 { 4263 {
4264 struct Lisp_Process *p; 4264 struct Lisp_Process *p;
4265 4265
4266 FD_CLR (channel, &connect_wait_mask); 4266 FD_CLR (channel, &connect_wait_mask);
4477 4477
4478 /* Read and dispose of the process output. */ 4478 /* Read and dispose of the process output. */
4479 outstream = p->filter; 4479 outstream = p->filter;
4480 if (!NILP (outstream)) 4480 if (!NILP (outstream))
4481 { 4481 {
4482 /* We inhibit quit here instead of just catching it so that 4482 /* We inhibit quit here instead of just catching it so that
4483 hitting ^G when a filter happens to be running won't screw 4483 hitting ^G when a filter happens to be running won't screw
4484 it up. */ 4484 it up. */
4485 int count = SPECPDL_INDEX (); 4485 int count = SPECPDL_INDEX ();
4486 Lisp_Object odeactivate; 4486 Lisp_Object odeactivate;
4487 Lisp_Object obuffer, okeymap; 4487 Lisp_Object obuffer, okeymap;
4943 #endif 4943 #endif
4944 #ifdef EAGAIN 4944 #ifdef EAGAIN
4945 || errno == EAGAIN 4945 || errno == EAGAIN
4946 #endif 4946 #endif
4947 ) 4947 )
4948 /* Buffer is full. Wait, accepting input; 4948 /* Buffer is full. Wait, accepting input;
4949 that may allow the program 4949 that may allow the program
4950 to finish doing output and read more. */ 4950 to finish doing output and read more. */
4951 { 4951 {
4952 Lisp_Object zero; 4952 Lisp_Object zero;
4953 int offset = 0; 4953 int offset = 0;
4967 read are the 1022 bytes written successfully 4967 read are the 1022 bytes written successfully
4968 after processing (for example with CRs added if 4968 after processing (for example with CRs added if
4969 the terminal is set up that way which it is 4969 the terminal is set up that way which it is
4970 here). The same bytes will be seen again in a 4970 here). The same bytes will be seen again in a
4971 later read(2), without the CRs. */ 4971 later read(2), without the CRs. */
4972 4972
4973 if (errno == EAGAIN) 4973 if (errno == EAGAIN)
4974 { 4974 {
4975 int flags = FWRITE; 4975 int flags = FWRITE;
4976 ioctl (XINT (XPROCESS (proc)->outfd), TIOCFLUSH, 4976 ioctl (XINT (XPROCESS (proc)->outfd), TIOCFLUSH,
4977 &flags); 4977 &flags);
4978 } 4978 }
4979 #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ 4979 #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
4980 4980
4981 /* Running filters might relocate buffers or strings. 4981 /* Running filters might relocate buffers or strings.
4982 Arrange to relocate BUF. */ 4982 Arrange to relocate BUF. */
4983 if (BUFFERP (object)) 4983 if (BUFFERP (object))
4984 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf); 4984 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf);
4985 else if (STRINGP (object)) 4985 else if (STRINGP (object))
5024 XPROCESS (proc)->raw_status_high = Qnil; 5024 XPROCESS (proc)->raw_status_high = Qnil;
5025 XPROCESS (proc)->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5025 XPROCESS (proc)->status = Fcons (Qexit, Fcons (make_number (256), Qnil));
5026 XSETINT (XPROCESS (proc)->tick, ++process_tick); 5026 XSETINT (XPROCESS (proc)->tick, ++process_tick);
5027 deactivate_process (proc); 5027 deactivate_process (proc);
5028 #ifdef VMS 5028 #ifdef VMS
5029 error ("Error writing to process %s; closed it", 5029 error ("Error writing to process %s; closed it",
5030 SDATA (XPROCESS (proc)->name)); 5030 SDATA (XPROCESS (proc)->name));
5031 #else 5031 #else
5032 error ("SIGPIPE raised on process %s; closed it", 5032 error ("SIGPIPE raised on process %s; closed it",
5033 SDATA (XPROCESS (proc)->name)); 5033 SDATA (XPROCESS (proc)->name));
5034 #endif 5034 #endif
5107 SDATA (p->name)); 5107 SDATA (p->name));
5108 if (XINT (p->infd) < 0) 5108 if (XINT (p->infd) < 0)
5109 error ("Process %s is not active", 5109 error ("Process %s is not active",
5110 SDATA (p->name)); 5110 SDATA (p->name));
5111 5111
5112 #ifdef TIOCGPGRP 5112 #ifdef TIOCGPGRP
5113 if (!NILP (p->subtty)) 5113 if (!NILP (p->subtty))
5114 ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); 5114 ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid);
5115 else 5115 else
5116 ioctl (XINT (p->infd), TIOCGPGRP, &gid); 5116 ioctl (XINT (p->infd), TIOCGPGRP, &gid);
5117 #endif /* defined (TIOCGPGRP ) */ 5117 #endif /* defined (TIOCGPGRP ) */
5256 #endif /* ! defined HAVE_TERMIOS */ 5256 #endif /* ! defined HAVE_TERMIOS */
5257 abort (); 5257 abort ();
5258 /* The code above always returns from the function. */ 5258 /* The code above always returns from the function. */
5259 #endif /* defined (SIGNALS_VIA_CHARACTERS) */ 5259 #endif /* defined (SIGNALS_VIA_CHARACTERS) */
5260 5260
5261 #ifdef TIOCGPGRP 5261 #ifdef TIOCGPGRP
5262 /* Get the current pgrp using the tty itself, if we have that. 5262 /* Get the current pgrp using the tty itself, if we have that.
5263 Otherwise, use the pty to get the pgrp. 5263 Otherwise, use the pty to get the pgrp.
5264 On pfa systems, saka@pfu.fujitsu.co.JP writes: 5264 On pfa systems, saka@pfu.fujitsu.co.JP writes:
5265 "TIOCGPGRP symbol defined in sys/ioctl.h at E50. 5265 "TIOCGPGRP symbol defined in sys/ioctl.h at E50.
5266 But, TIOCGPGRP does not work on E50 ;-P works fine on E60" 5266 But, TIOCGPGRP does not work on E50 ;-P works fine on E60"
5390 return process; 5390 return process;
5391 } 5391 }
5392 5392
5393 DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0, 5393 DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0,
5394 doc: /* Stop process PROCESS. May be process or name of one. 5394 doc: /* Stop process PROCESS. May be process or name of one.
5395 See function `interrupt-process' for more details on usage. 5395 See function `interrupt-process' for more details on usage.
5396 If PROCESS is a network process, inhibit handling of incoming traffic. */) 5396 If PROCESS is a network process, inhibit handling of incoming traffic. */)
5397 (process, current_group) 5397 (process, current_group)
5398 Lisp_Object process, current_group; 5398 Lisp_Object process, current_group;
5399 { 5399 {
5400 #ifdef HAVE_SOCKETS 5400 #ifdef HAVE_SOCKETS
5401 if (PROCESSP (process) && NETCONN_P (process)) 5401 if (PROCESSP (process) && NETCONN_P (process))
5402 { 5402 {
5403 struct Lisp_Process *p; 5403 struct Lisp_Process *p;
5404 5404
5405 p = XPROCESS (process); 5405 p = XPROCESS (process);
5406 if (NILP (p->command) 5406 if (NILP (p->command)
5407 && XINT (p->infd) >= 0) 5407 && XINT (p->infd) >= 0)
5408 { 5408 {
5409 FD_CLR (XINT (p->infd), &input_wait_mask); 5409 FD_CLR (XINT (p->infd), &input_wait_mask);
5421 return process; 5421 return process;
5422 } 5422 }
5423 5423
5424 DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0, 5424 DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0,
5425 doc: /* Continue process PROCESS. May be process or name of one. 5425 doc: /* Continue process PROCESS. May be process or name of one.
5426 See function `interrupt-process' for more details on usage. 5426 See function `interrupt-process' for more details on usage.
5427 If PROCESS is a network process, resume handling of incoming traffic. */) 5427 If PROCESS is a network process, resume handling of incoming traffic. */)
5428 (process, current_group) 5428 (process, current_group)
5429 Lisp_Object process, current_group; 5429 Lisp_Object process, current_group;
5430 { 5430 {
5431 #ifdef HAVE_SOCKETS 5431 #ifdef HAVE_SOCKETS
5482 } 5482 }
5483 process = tem; 5483 process = tem;
5484 } 5484 }
5485 else 5485 else
5486 process = get_process (process); 5486 process = get_process (process);
5487 5487
5488 if (NILP (process)) 5488 if (NILP (process))
5489 return process; 5489 return process;
5490 5490
5491 CHECK_PROCESS (process); 5491 CHECK_PROCESS (process);
5492 pid = XPROCESS (process)->pid; 5492 pid = XPROCESS (process)->pid;
5706 } 5706 }
5707 5707
5708 /* On receipt of a signal that a child status has changed, loop asking 5708 /* On receipt of a signal that a child status has changed, loop asking
5709 about children with changed statuses until the system says there 5709 about children with changed statuses until the system says there
5710 are no more. 5710 are no more.
5711 5711
5712 All we do is change the status; we do not run sentinels or print 5712 All we do is change the status; we do not run sentinels or print
5713 notifications. That is saved for the next time keyboard input is 5713 notifications. That is saved for the next time keyboard input is
5714 done, in order to avoid timing errors. 5714 done, in order to avoid timing errors.
5715 5715
5716 ** WARNING: this can be called during garbage collection. 5716 ** WARNING: this can be called during garbage collection.
5750 #ifdef WNOHANG 5750 #ifdef WNOHANG
5751 #ifndef WUNTRACED 5751 #ifndef WUNTRACED
5752 #define WUNTRACED 0 5752 #define WUNTRACED 0
5753 #endif /* no WUNTRACED */ 5753 #endif /* no WUNTRACED */
5754 /* Keep trying to get a status until we get a definitive result. */ 5754 /* Keep trying to get a status until we get a definitive result. */
5755 do 5755 do
5756 { 5756 {
5757 errno = 0; 5757 errno = 0;
5758 pid = wait3 (&w, WNOHANG | WUNTRACED, 0); 5758 pid = wait3 (&w, WNOHANG | WUNTRACED, 0);
5759 } 5759 }
5760 while (pid < 0 && errno == EINTR); 5760 while (pid < 0 && errno == EINTR);
5801 p = XPROCESS (proc); 5801 p = XPROCESS (proc);
5802 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1) 5802 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1)
5803 break; 5803 break;
5804 p = 0; 5804 p = 0;
5805 } 5805 }
5806 5806
5807 /* Change the status of the process that was found. */ 5807 /* Change the status of the process that was found. */
5808 if (p != 0) 5808 if (p != 0)
5809 { 5809 {
5810 union { int i; WAITTYPE wt; } u; 5810 union { int i; WAITTYPE wt; } u;
5811 int clear_desc_flag = 0; 5811 int clear_desc_flag = 0;
5812 5812
5813 XSETINT (p->tick, ++process_tick); 5813 XSETINT (p->tick, ++process_tick);
5814 u.wt = w; 5814 u.wt = w;
5815 XSETINT (p->raw_status_low, u.i & 0xffff); 5815 XSETINT (p->raw_status_low, u.i & 0xffff);
5816 XSETINT (p->raw_status_high, u.i >> 16); 5816 XSETINT (p->raw_status_high, u.i >> 16);
5817 5817
5818 /* If process has terminated, stop waiting for its output. */ 5818 /* If process has terminated, stop waiting for its output. */
5819 if ((WIFSIGNALED (w) || WIFEXITED (w)) 5819 if ((WIFSIGNALED (w) || WIFEXITED (w))
5820 && XINT (p->infd) >= 0) 5820 && XINT (p->infd) >= 0)
5821 clear_desc_flag = 1; 5821 clear_desc_flag = 1;
5822 5822
6340 staticpro (&QCstop); 6340 staticpro (&QCstop);
6341 QCoptions = intern (":options"); 6341 QCoptions = intern (":options");
6342 staticpro (&QCoptions); 6342 staticpro (&QCoptions);
6343 QCplist = intern (":plist"); 6343 QCplist = intern (":plist");
6344 staticpro (&QCplist); 6344 staticpro (&QCplist);
6345 6345
6346 Qlast_nonmenu_event = intern ("last-nonmenu-event"); 6346 Qlast_nonmenu_event = intern ("last-nonmenu-event");
6347 staticpro (&Qlast_nonmenu_event); 6347 staticpro (&Qlast_nonmenu_event);
6348 6348
6349 staticpro (&Vprocess_alist); 6349 staticpro (&Vprocess_alist);
6350 6350
6470 EMACS_TIME end_time, timeout; 6470 EMACS_TIME end_time, timeout;
6471 SELECT_TYPE waitchannels; 6471 SELECT_TYPE waitchannels;
6472 int xerrno; 6472 int xerrno;
6473 /* Either nil or a cons cell, the car of which is of interest and 6473 /* Either nil or a cons cell, the car of which is of interest and
6474 may be changed outside of this routine. */ 6474 may be changed outside of this routine. */
6475 Lisp_Object wait_for_cell; 6475 Lisp_Object wait_for_cell;
6476 6476
6477 wait_for_cell = Qnil; 6477 wait_for_cell = Qnil;
6478 6478
6479 /* If waiting for non-nil in a cell, record where. */ 6479 /* If waiting for non-nil in a cell, record where. */
6480 if (CONSP (read_kbd)) 6480 if (CONSP (read_kbd))