aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c299
1 files changed, 144 insertions, 155 deletions
diff --git a/src/process.c b/src/process.c
index 067eae7f286..5551c0610d0 100644
--- a/src/process.c
+++ b/src/process.c
@@ -121,14 +121,6 @@ Boston, MA 02110-1301, USA. */
121#include <sys/wait.h> 121#include <sys/wait.h>
122#endif 122#endif
123 123
124/* Disable IPv6 support for w32 until someone figures out how to do it
125 properly. */
126#ifdef WINDOWSNT
127# ifdef AF_INET6
128# undef AF_INET6
129# endif
130#endif
131
132#include "lisp.h" 124#include "lisp.h"
133#include "systime.h" 125#include "systime.h"
134#include "systty.h" 126#include "systty.h"
@@ -393,7 +385,7 @@ struct sockaddr_and_len {
393 int len; 385 int len;
394} datagram_address[MAXDESC]; 386} datagram_address[MAXDESC];
395#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0) 387#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0)
396#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XINT (XPROCESS (proc)->infd)].sa != 0) 388#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0)
397#else 389#else
398#define DATAGRAM_CHAN_P(chan) (0) 390#define DATAGRAM_CHAN_P(chan) (0)
399#define DATAGRAM_CONN_P(proc) (0) 391#define DATAGRAM_CONN_P(proc) (0)
@@ -628,19 +620,19 @@ make_process (name)
628 620
629 p = allocate_process (); 621 p = allocate_process ();
630 622
631 XSETINT (p->infd, -1); 623 p->infd = -1;
632 XSETINT (p->outfd, -1); 624 p->outfd = -1;
633 XSETFASTINT (p->tick, 0); 625 p->tick = 0;
634 XSETFASTINT (p->update_tick, 0); 626 p->update_tick = 0;
635 p->pid = 0; 627 p->pid = 0;
636 p->raw_status_new = 0; 628 p->raw_status_new = 0;
637 p->status = Qrun; 629 p->status = Qrun;
638 p->mark = Fmake_marker (); 630 p->mark = Fmake_marker ();
639 631
640#ifdef ADAPTIVE_READ_BUFFERING 632#ifdef ADAPTIVE_READ_BUFFERING
641 p->adaptive_read_buffering = Qnil; 633 p->adaptive_read_buffering = 0;
642 XSETFASTINT (p->read_output_delay, 0); 634 p->read_output_delay = 0;
643 p->read_output_skip = Qnil; 635 p->read_output_skip = 0;
644#endif 636#endif
645 637
646 /* If name is already in use, modify it until it is unused. */ 638 /* If name is already in use, modify it until it is unused. */
@@ -679,8 +671,8 @@ setup_process_coding_systems (process)
679 Lisp_Object process; 671 Lisp_Object process;
680{ 672{
681 struct Lisp_Process *p = XPROCESS (process); 673 struct Lisp_Process *p = XPROCESS (process);
682 int inch = XINT (p->infd); 674 int inch = p->infd;
683 int outch = XINT (p->outfd); 675 int outch = p->outfd;
684 Lisp_Object coding_system; 676 Lisp_Object coding_system;
685 677
686 if (inch < 0 || outch < 0) 678 if (inch < 0 || outch < 0)
@@ -692,7 +684,7 @@ setup_process_coding_systems (process)
692 coding_system = p->decode_coding_system; 684 coding_system = p->decode_coding_system;
693 if (! NILP (p->filter)) 685 if (! NILP (p->filter))
694 { 686 {
695 if (NILP (p->filter_multibyte)) 687 if (!p->filter_multibyte)
696 coding_system = raw_text_coding_system (coding_system); 688 coding_system = raw_text_coding_system (coding_system);
697 } 689 }
698 else if (BUFFERP (p->buffer)) 690 else if (BUFFERP (p->buffer))
@@ -814,10 +806,10 @@ nil, indicating the current buffer's process. */)
814 if (NETCONN1_P (p)) 806 if (NETCONN1_P (p))
815 { 807 {
816 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 808 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
817 XSETINT (p->tick, ++process_tick); 809 p->tick = ++process_tick;
818 status_notify (p); 810 status_notify (p);
819 } 811 }
820 else if (XINT (p->infd) >= 0) 812 else if (p->infd >= 0)
821 { 813 {
822#ifdef SIGCHLD 814#ifdef SIGCHLD
823 Lisp_Object symbol; 815 Lisp_Object symbol;
@@ -845,7 +837,7 @@ nil, indicating the current buffer's process. */)
845 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 837 /* Do this now, since remove_process will make sigchld_handler do nothing. */
846 p->status 838 p->status
847 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); 839 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil));
848 XSETINT (p->tick, ++process_tick); 840 p->tick = ++process_tick;
849 status_notify (p); 841 status_notify (p);
850 } 842 }
851 } 843 }
@@ -1037,18 +1029,18 @@ The string argument is normally a multibyte string, except:
1037 (debug) 1029 (debug)
1038 (set-process-filter process ...) */ 1030 (set-process-filter process ...) */
1039 1031
1040 if (XINT (p->infd) >= 0) 1032 if (p->infd >= 0)
1041 { 1033 {
1042 if (EQ (filter, Qt) && !EQ (p->status, Qlisten)) 1034 if (EQ (filter, Qt) && !EQ (p->status, Qlisten))
1043 { 1035 {
1044 FD_CLR (XINT (p->infd), &input_wait_mask); 1036 FD_CLR (p->infd, &input_wait_mask);
1045 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 1037 FD_CLR (p->infd, &non_keyboard_wait_mask);
1046 } 1038 }
1047 else if (EQ (p->filter, Qt) 1039 else if (EQ (p->filter, Qt)
1048 && !EQ (p->command, Qt)) /* Network process not stopped. */ 1040 && !EQ (p->command, Qt)) /* Network process not stopped. */
1049 { 1041 {
1050 FD_SET (XINT (p->infd), &input_wait_mask); 1042 FD_SET (p->infd, &input_wait_mask);
1051 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 1043 FD_SET (p->infd, &non_keyboard_wait_mask);
1052 } 1044 }
1053 } 1045 }
1054 1046
@@ -1110,8 +1102,8 @@ DEFUN ("set-process-window-size", Fset_process_window_size,
1110 CHECK_NATNUM (height); 1102 CHECK_NATNUM (height);
1111 CHECK_NATNUM (width); 1103 CHECK_NATNUM (width);
1112 1104
1113 if (XINT (XPROCESS (process)->infd) < 0 1105 if (XPROCESS (process)->infd < 0
1114 || set_window_size (XINT (XPROCESS (process)->infd), 1106 || set_window_size (XPROCESS (process)->infd,
1115 XINT (height), XINT (width)) <= 0) 1107 XINT (height), XINT (width)) <= 0)
1116 return Qnil; 1108 return Qnil;
1117 else 1109 else
@@ -1139,7 +1131,7 @@ for the process which will run. */)
1139 register Lisp_Object process, flag; 1131 register Lisp_Object process, flag;
1140{ 1132{
1141 CHECK_PROCESS (process); 1133 CHECK_PROCESS (process);
1142 XPROCESS (process)->inherit_coding_system_flag = flag; 1134 XPROCESS (process)->inherit_coding_system_flag = !NILP (flag);
1143 return flag; 1135 return flag;
1144} 1136}
1145 1137
@@ -1154,7 +1146,7 @@ the process output. */)
1154 register Lisp_Object process; 1146 register Lisp_Object process;
1155{ 1147{
1156 CHECK_PROCESS (process); 1148 CHECK_PROCESS (process);
1157 return XPROCESS (process)->inherit_coding_system_flag; 1149 return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil;
1158} 1150}
1159 1151
1160DEFUN ("set-process-query-on-exit-flag", 1152DEFUN ("set-process-query-on-exit-flag",
@@ -1167,7 +1159,7 @@ exiting if PROCESS is running. */)
1167 register Lisp_Object process, flag; 1159 register Lisp_Object process, flag;
1168{ 1160{
1169 CHECK_PROCESS (process); 1161 CHECK_PROCESS (process);
1170 XPROCESS (process)->kill_without_query = Fnull (flag); 1162 XPROCESS (process)->kill_without_query = NILP (flag);
1171 return flag; 1163 return flag;
1172} 1164}
1173 1165
@@ -1179,7 +1171,7 @@ DEFUN ("process-query-on-exit-flag",
1179 register Lisp_Object process; 1171 register Lisp_Object process;
1180{ 1172{
1181 CHECK_PROCESS (process); 1173 CHECK_PROCESS (process);
1182 return Fnull (XPROCESS (process)->kill_without_query); 1174 return (XPROCESS (process)->kill_without_query ? Qnil : Qt);
1183} 1175}
1184 1176
1185#ifdef DATAGRAM_SOCKETS 1177#ifdef DATAGRAM_SOCKETS
@@ -1354,7 +1346,7 @@ list_processes_1 (query_only)
1354 p = XPROCESS (proc); 1346 p = XPROCESS (proc);
1355 if (NILP (p->childp)) 1347 if (NILP (p->childp))
1356 continue; 1348 continue;
1357 if (!NILP (query_only) && !NILP (p->kill_without_query)) 1349 if (!NILP (query_only) && p->kill_without_query)
1358 continue; 1350 continue;
1359 if (STRINGP (p->name) 1351 if (STRINGP (p->name)
1360 && ( i = SCHARS (p->name), (i > w_proc))) 1352 && ( i = SCHARS (p->name), (i > w_proc)))
@@ -1417,7 +1409,7 @@ list_processes_1 (query_only)
1417 p = XPROCESS (proc); 1409 p = XPROCESS (proc);
1418 if (NILP (p->childp)) 1410 if (NILP (p->childp))
1419 continue; 1411 continue;
1420 if (!NILP (query_only) && !NILP (p->kill_without_query)) 1412 if (!NILP (query_only) && p->kill_without_query)
1421 continue; 1413 continue;
1422 1414
1423 Finsert (1, &p->name); 1415 Finsert (1, &p->name);
@@ -1493,7 +1485,7 @@ list_processes_1 (query_only)
1493 if (NILP (port)) 1485 if (NILP (port))
1494 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); 1486 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil);
1495 sprintf (tembuf, "(network %s server on %s)\n", 1487 sprintf (tembuf, "(network %s server on %s)\n",
1496 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1488 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1497 (STRINGP (port) ? (char *)SDATA (port) : "?")); 1489 (STRINGP (port) ? (char *)SDATA (port) : "?"));
1498 insert_string (tembuf); 1490 insert_string (tembuf);
1499 } 1491 }
@@ -1511,7 +1503,7 @@ list_processes_1 (query_only)
1511 if (NILP (host)) 1503 if (NILP (host))
1512 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); 1504 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil);
1513 sprintf (tembuf, "(network %s connection to %s)\n", 1505 sprintf (tembuf, "(network %s connection to %s)\n",
1514 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1506 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1515 (STRINGP (host) ? (char *)SDATA (host) : "?")); 1507 (STRINGP (host) ? (char *)SDATA (host) : "?"));
1516 insert_string (tembuf); 1508 insert_string (tembuf);
1517 } 1509 }
@@ -1642,11 +1634,13 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1642 XPROCESS (proc)->sentinel = Qnil; 1634 XPROCESS (proc)->sentinel = Qnil;
1643 XPROCESS (proc)->filter = Qnil; 1635 XPROCESS (proc)->filter = Qnil;
1644 XPROCESS (proc)->filter_multibyte 1636 XPROCESS (proc)->filter_multibyte
1645 = buffer_defaults.enable_multibyte_characters; 1637 = !NILP (buffer_defaults.enable_multibyte_characters);
1646 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1638 XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1647 1639
1648#ifdef ADAPTIVE_READ_BUFFERING 1640#ifdef ADAPTIVE_READ_BUFFERING
1649 XPROCESS (proc)->adaptive_read_buffering = Vprocess_adaptive_read_buffering; 1641 XPROCESS (proc)->adaptive_read_buffering
1642 = (NILP (Vprocess_adaptive_read_buffering) ? 0
1643 : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2);
1650#endif 1644#endif
1651 1645
1652 /* Make the process marker point into the process buffer (if any). */ 1646 /* Make the process marker point into the process buffer (if any). */
@@ -1777,13 +1771,11 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1777#endif /* not VMS */ 1771#endif /* not VMS */
1778 1772
1779 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 1773 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
1780 XPROCESS (proc)->decoding_carryover = make_number (0); 1774 XPROCESS (proc)->decoding_carryover = 0;
1781 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 1775 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
1782 XPROCESS (proc)->encoding_carryover = make_number (0);
1783 1776
1784 XPROCESS (proc)->inherit_coding_system_flag 1777 XPROCESS (proc)->inherit_coding_system_flag
1785 = (NILP (buffer) || !inherit_process_coding_system 1778 = (NILP (buffer) || !inherit_process_coding_system);
1786 ? Qnil : Qt);
1787 1779
1788 create_process (proc, (char **) new_argv, current_dir); 1780 create_process (proc, (char **) new_argv, current_dir);
1789 1781
@@ -1955,15 +1947,15 @@ create_process (process, new_argv, current_dir)
1955 /* Record this as an active process, with its channels. 1947 /* Record this as an active process, with its channels.
1956 As a result, child_setup will close Emacs's side of the pipes. */ 1948 As a result, child_setup will close Emacs's side of the pipes. */
1957 chan_process[inchannel] = process; 1949 chan_process[inchannel] = process;
1958 XSETINT (XPROCESS (process)->infd, inchannel); 1950 XPROCESS (process)->infd = inchannel;
1959 XSETINT (XPROCESS (process)->outfd, outchannel); 1951 XPROCESS (process)->outfd = outchannel;
1960 1952
1961 /* Previously we recorded the tty descriptor used in the subprocess. 1953 /* Previously we recorded the tty descriptor used in the subprocess.
1962 It was only used for getting the foreground tty process, so now 1954 It was only used for getting the foreground tty process, so now
1963 we just reopen the device (see emacs_get_tty_pgrp) as this is 1955 we just reopen the device (see emacs_get_tty_pgrp) as this is
1964 more portable (see USG_SUBTTY_WORKS above). */ 1956 more portable (see USG_SUBTTY_WORKS above). */
1965 1957
1966 XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); 1958 XPROCESS (process)->pty_flag = pty_flag;
1967 XPROCESS (process)->status = Qrun; 1959 XPROCESS (process)->status = Qrun;
1968 setup_process_coding_systems (process); 1960 setup_process_coding_systems (process);
1969 1961
@@ -2480,7 +2472,7 @@ DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_
2480 if (!DATAGRAM_CONN_P (process)) 2472 if (!DATAGRAM_CONN_P (process))
2481 return Qnil; 2473 return Qnil;
2482 2474
2483 channel = XINT (XPROCESS (process)->infd); 2475 channel = XPROCESS (process)->infd;
2484 return conv_sockaddr_to_lisp (datagram_address[channel].sa, 2476 return conv_sockaddr_to_lisp (datagram_address[channel].sa,
2485 datagram_address[channel].len); 2477 datagram_address[channel].len);
2486} 2478}
@@ -2500,7 +2492,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */)
2500 if (!DATAGRAM_CONN_P (process)) 2492 if (!DATAGRAM_CONN_P (process))
2501 return Qnil; 2493 return Qnil;
2502 2494
2503 channel = XINT (XPROCESS (process)->infd); 2495 channel = XPROCESS (process)->infd;
2504 2496
2505 len = get_lisp_to_sockaddr_size (address, &family); 2497 len = get_lisp_to_sockaddr_size (address, &family);
2506 if (datagram_address[channel].len != len) 2498 if (datagram_address[channel].len != len)
@@ -2665,7 +2657,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */)
2665 if (!NETCONN1_P (p)) 2657 if (!NETCONN1_P (p))
2666 error ("Process is not a network process"); 2658 error ("Process is not a network process");
2667 2659
2668 s = XINT (p->infd); 2660 s = p->infd;
2669 if (s < 0) 2661 if (s < 0)
2670 error ("Process is not running"); 2662 error ("Process is not running");
2671 2663
@@ -3419,18 +3411,18 @@ usage: (make-network-process &rest ARGS) */)
3419 p->buffer = buffer; 3411 p->buffer = buffer;
3420 p->sentinel = sentinel; 3412 p->sentinel = sentinel;
3421 p->filter = filter; 3413 p->filter = filter;
3422 p->filter_multibyte = buffer_defaults.enable_multibyte_characters; 3414 p->filter_multibyte = !NILP (buffer_defaults.enable_multibyte_characters);
3423 /* Override the above only if :filter-multibyte is specified. */ 3415 /* Override the above only if :filter-multibyte is specified. */
3424 if (! NILP (Fplist_member (contact, QCfilter_multibyte))) 3416 if (! NILP (Fplist_member (contact, QCfilter_multibyte)))
3425 p->filter_multibyte = Fplist_get (contact, QCfilter_multibyte); 3417 p->filter_multibyte = !NILP (Fplist_get (contact, QCfilter_multibyte));
3426 p->log = Fplist_get (contact, QClog); 3418 p->log = Fplist_get (contact, QClog);
3427 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 3419 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3428 p->kill_without_query = Qt; 3420 p->kill_without_query = 1;
3429 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) 3421 if ((tem = Fplist_get (contact, QCstop), !NILP (tem)))
3430 p->command = Qt; 3422 p->command = Qt;
3431 p->pid = 0; 3423 p->pid = 0;
3432 XSETINT (p->infd, inch); 3424 p->infd = inch;
3433 XSETINT (p->outfd, outch); 3425 p->outfd = outch;
3434 if (is_server && socktype == SOCK_STREAM) 3426 if (is_server && socktype == SOCK_STREAM)
3435 p->status = Qlisten; 3427 p->status = Qlisten;
3436 3428
@@ -3551,13 +3543,11 @@ usage: (make-network-process &rest ARGS) */)
3551 setup_process_coding_systems (proc); 3543 setup_process_coding_systems (proc);
3552 3544
3553 p->decoding_buf = make_uninit_string (0); 3545 p->decoding_buf = make_uninit_string (0);
3554 p->decoding_carryover = make_number (0); 3546 p->decoding_carryover = 0;
3555 p->encoding_buf = make_uninit_string (0); 3547 p->encoding_buf = make_uninit_string (0);
3556 p->encoding_carryover = make_number (0);
3557 3548
3558 p->inherit_coding_system_flag 3549 p->inherit_coding_system_flag
3559 = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system 3550 = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
3560 ? Qnil : Qt);
3561 3551
3562 UNGCPRO; 3552 UNGCPRO;
3563 return proc; 3553 return proc;
@@ -3820,16 +3810,16 @@ deactivate_process (proc)
3820 register int inchannel, outchannel; 3810 register int inchannel, outchannel;
3821 register struct Lisp_Process *p = XPROCESS (proc); 3811 register struct Lisp_Process *p = XPROCESS (proc);
3822 3812
3823 inchannel = XINT (p->infd); 3813 inchannel = p->infd;
3824 outchannel = XINT (p->outfd); 3814 outchannel = p->outfd;
3825 3815
3826#ifdef ADAPTIVE_READ_BUFFERING 3816#ifdef ADAPTIVE_READ_BUFFERING
3827 if (XINT (p->read_output_delay) > 0) 3817 if (p->read_output_delay > 0)
3828 { 3818 {
3829 if (--process_output_delay_count < 0) 3819 if (--process_output_delay_count < 0)
3830 process_output_delay_count = 0; 3820 process_output_delay_count = 0;
3831 XSETINT (p->read_output_delay, 0); 3821 p->read_output_delay = 0;
3832 p->read_output_skip = Qnil; 3822 p->read_output_skip = 0;
3833 } 3823 }
3834#endif 3824#endif
3835 3825
@@ -3851,8 +3841,8 @@ deactivate_process (proc)
3851 emacs_close (outchannel); 3841 emacs_close (outchannel);
3852#endif 3842#endif
3853 3843
3854 XSETINT (p->infd, -1); 3844 p->infd = -1;
3855 XSETINT (p->outfd, -1); 3845 p->outfd = -1;
3856#ifdef DATAGRAM_SOCKETS 3846#ifdef DATAGRAM_SOCKETS
3857 if (DATAGRAM_CHAN_P (inchannel)) 3847 if (DATAGRAM_CHAN_P (inchannel))
3858 { 3848 {
@@ -3900,8 +3890,8 @@ close_process_descs ()
3900 process = chan_process[i]; 3890 process = chan_process[i];
3901 if (!NILP (process)) 3891 if (!NILP (process))
3902 { 3892 {
3903 int in = XINT (XPROCESS (process)->infd); 3893 int in = XPROCESS (process)->infd;
3904 int out = XINT (XPROCESS (process)->outfd); 3894 int out = XPROCESS (process)->outfd;
3905 if (in >= 0) 3895 if (in >= 0)
3906 emacs_close (in); 3896 emacs_close (in);
3907 if (out >= 0 && in != out) 3897 if (out >= 0 && in != out)
@@ -4145,8 +4135,8 @@ server_accept_connection (server, channel)
4145 p->filter = ps->filter; 4135 p->filter = ps->filter;
4146 p->command = Qnil; 4136 p->command = Qnil;
4147 p->pid = 0; 4137 p->pid = 0;
4148 XSETINT (p->infd, s); 4138 p->infd = s;
4149 XSETINT (p->outfd, s); 4139 p->outfd = s;
4150 p->status = Qrun; 4140 p->status = Qrun;
4151 4141
4152 /* Client processes for accepted connections are not stopped initially. */ 4142 /* Client processes for accepted connections are not stopped initially. */
@@ -4169,12 +4159,11 @@ server_accept_connection (server, channel)
4169 setup_process_coding_systems (proc); 4159 setup_process_coding_systems (proc);
4170 4160
4171 p->decoding_buf = make_uninit_string (0); 4161 p->decoding_buf = make_uninit_string (0);
4172 p->decoding_carryover = make_number (0); 4162 p->decoding_carryover = 0;
4173 p->encoding_buf = make_uninit_string (0); 4163 p->encoding_buf = make_uninit_string (0);
4174 p->encoding_carryover = make_number (0);
4175 4164
4176 p->inherit_coding_system_flag 4165 p->inherit_coding_system_flag
4177 = (NILP (buffer) ? Qnil : ps->inherit_coding_system_flag); 4166 = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag);
4178 4167
4179 if (!NILP (ps->log)) 4168 if (!NILP (ps->log))
4180 call3 (ps->log, server, proc, 4169 call3 (ps->log, server, proc,
@@ -4299,7 +4288,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4299 4288
4300 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4289 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4301 if (wait_proc != NULL) 4290 if (wait_proc != NULL)
4302 wait_channel = XINT (wait_proc->infd); 4291 wait_channel = wait_proc->infd;
4303 4292
4304 record_unwind_protect (wait_reading_process_output_unwind, 4293 record_unwind_protect (wait_reading_process_output_unwind,
4305 make_number (waiting_for_user_input_p)); 4294 make_number (waiting_for_user_input_p));
@@ -4484,9 +4473,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4484 XSETPROCESS (proc, wait_proc); 4473 XSETPROCESS (proc, wait_proc);
4485 4474
4486 /* Read data from the process, until we exhaust it. */ 4475 /* Read data from the process, until we exhaust it. */
4487 while (XINT (wait_proc->infd) >= 0) 4476 while (wait_proc->infd >= 0)
4488 { 4477 {
4489 nread = read_process_output (proc, XINT (wait_proc->infd)); 4478 nread = read_process_output (proc, wait_proc->infd);
4490 4479
4491 if (nread == 0) 4480 if (nread == 0)
4492 break; 4481 break;
@@ -4516,9 +4505,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4516 4505
4517 if (wait_proc && just_wait_proc) 4506 if (wait_proc && just_wait_proc)
4518 { 4507 {
4519 if (XINT (wait_proc->infd) < 0) /* Terminated */ 4508 if (wait_proc->infd < 0) /* Terminated */
4520 break; 4509 break;
4521 FD_SET (XINT (wait_proc->infd), &Available); 4510 FD_SET (wait_proc->infd, &Available);
4522 check_delay = 0; 4511 check_delay = 0;
4523 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4512 IF_NON_BLOCKING_CONNECT (check_connect = 0);
4524 } 4513 }
@@ -4566,7 +4555,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4566 4555
4567#ifdef ADAPTIVE_READ_BUFFERING 4556#ifdef ADAPTIVE_READ_BUFFERING
4568 /* Set the timeout for adaptive read buffering if any 4557 /* Set the timeout for adaptive read buffering if any
4569 process has non-nil read_output_skip and non-zero 4558 process has non-zero read_output_skip and non-zero
4570 read_output_delay, and we are not reading output for a 4559 read_output_delay, and we are not reading output for a
4571 specific wait_channel. It is not executed if 4560 specific wait_channel. It is not executed if
4572 Vprocess_adaptive_read_buffering is nil. */ 4561 Vprocess_adaptive_read_buffering is nil. */
@@ -4581,16 +4570,16 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4581 if (NILP (proc)) 4570 if (NILP (proc))
4582 continue; 4571 continue;
4583 /* Find minimum non-zero read_output_delay among the 4572 /* Find minimum non-zero read_output_delay among the
4584 processes with non-nil read_output_skip. */ 4573 processes with non-zero read_output_skip. */
4585 if (XINT (XPROCESS (proc)->read_output_delay) > 0) 4574 if (XPROCESS (proc)->read_output_delay > 0)
4586 { 4575 {
4587 check_delay--; 4576 check_delay--;
4588 if (NILP (XPROCESS (proc)->read_output_skip)) 4577 if (!XPROCESS (proc)->read_output_skip)
4589 continue; 4578 continue;
4590 FD_CLR (channel, &Available); 4579 FD_CLR (channel, &Available);
4591 XPROCESS (proc)->read_output_skip = Qnil; 4580 XPROCESS (proc)->read_output_skip = 0;
4592 if (XINT (XPROCESS (proc)->read_output_delay) < usecs) 4581 if (XPROCESS (proc)->read_output_delay < usecs)
4593 usecs = XINT (XPROCESS (proc)->read_output_delay); 4582 usecs = XPROCESS (proc)->read_output_delay;
4594 } 4583 }
4595 } 4584 }
4596 EMACS_SET_SECS_USECS (timeout, 0, usecs); 4585 EMACS_SET_SECS_USECS (timeout, 0, usecs);
@@ -4863,7 +4852,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4863 else 4852 else
4864 { 4853 {
4865 /* Preserve status of processes already terminated. */ 4854 /* Preserve status of processes already terminated. */
4866 XSETINT (XPROCESS (proc)->tick, ++process_tick); 4855 XPROCESS (proc)->tick = ++process_tick;
4867 deactivate_process (proc); 4856 deactivate_process (proc);
4868 if (XPROCESS (proc)->raw_status_new) 4857 if (XPROCESS (proc)->raw_status_new)
4869 update_status (XPROCESS (proc)); 4858 update_status (XPROCESS (proc));
@@ -4915,7 +4904,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4915#endif 4904#endif
4916 if (xerrno) 4905 if (xerrno)
4917 { 4906 {
4918 XSETINT (p->tick, ++process_tick); 4907 p->tick = ++process_tick;
4919 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)); 4908 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil));
4920 deactivate_process (proc); 4909 deactivate_process (proc);
4921 } 4910 }
@@ -4928,8 +4917,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4928 exec_sentinel (proc, build_string ("open\n")); 4917 exec_sentinel (proc, build_string ("open\n"));
4929 if (!EQ (p->filter, Qt) && !EQ (p->command, Qt)) 4918 if (!EQ (p->filter, Qt) && !EQ (p->command, Qt))
4930 { 4919 {
4931 FD_SET (XINT (p->infd), &input_wait_mask); 4920 FD_SET (p->infd, &input_wait_mask);
4932 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 4921 FD_SET (p->infd, &non_keyboard_wait_mask);
4933 } 4922 }
4934 } 4923 }
4935 } 4924 }
@@ -5003,7 +4992,7 @@ read_process_output (proc, channel)
5003 register struct Lisp_Process *p = XPROCESS (proc); 4992 register struct Lisp_Process *p = XPROCESS (proc);
5004 register int opoint; 4993 register int opoint;
5005 struct coding_system *coding = proc_decode_coding_system[channel]; 4994 struct coding_system *coding = proc_decode_coding_system[channel];
5006 int carryover = XINT (p->decoding_carryover); 4995 int carryover = p->decoding_carryover;
5007 int readmax = 4096; 4996 int readmax = 4096;
5008 4997
5009#ifdef VMS 4998#ifdef VMS
@@ -5056,9 +5045,9 @@ read_process_output (proc, channel)
5056 { 5045 {
5057 nbytes = emacs_read (channel, chars + carryover, readmax); 5046 nbytes = emacs_read (channel, chars + carryover, readmax);
5058#ifdef ADAPTIVE_READ_BUFFERING 5047#ifdef ADAPTIVE_READ_BUFFERING
5059 if (nbytes > 0 && !NILP (p->adaptive_read_buffering)) 5048 if (nbytes > 0 && p->adaptive_read_buffering)
5060 { 5049 {
5061 int delay = XINT (p->read_output_delay); 5050 int delay = p->read_output_delay;
5062 if (nbytes < 256) 5051 if (nbytes < 256)
5063 { 5052 {
5064 if (delay < READ_OUTPUT_DELAY_MAX_MAX) 5053 if (delay < READ_OUTPUT_DELAY_MAX_MAX)
@@ -5074,10 +5063,10 @@ read_process_output (proc, channel)
5074 if (delay == 0) 5063 if (delay == 0)
5075 process_output_delay_count--; 5064 process_output_delay_count--;
5076 } 5065 }
5077 XSETINT (p->read_output_delay, delay); 5066 p->read_output_delay = delay;
5078 if (delay) 5067 if (delay)
5079 { 5068 {
5080 p->read_output_skip = Qt; 5069 p->read_output_skip = 1;
5081 process_output_skip = 1; 5070 process_output_skip = 1;
5082 } 5071 }
5083 } 5072 }
@@ -5095,7 +5084,7 @@ read_process_output (proc, channel)
5095 } 5084 }
5096#endif /* not VMS */ 5085#endif /* not VMS */
5097 5086
5098 XSETINT (p->decoding_carryover, 0); 5087 p->decoding_carryover = 0;
5099 5088
5100 /* At this point, NBYTES holds number of bytes just received 5089 /* At this point, NBYTES holds number of bytes just received
5101 (including the one in proc_buffered_char[channel]). */ 5090 (including the one in proc_buffered_char[channel]). */
@@ -5169,12 +5158,12 @@ read_process_output (proc, channel)
5169 valid memory because p->outfd will be changed once EOF is 5158 valid memory because p->outfd will be changed once EOF is
5170 sent to the process. */ 5159 sent to the process. */
5171 if (NILP (p->encode_coding_system) 5160 if (NILP (p->encode_coding_system)
5172 && proc_encode_coding_system[XINT (p->outfd)]) 5161 && proc_encode_coding_system[p->outfd])
5173 { 5162 {
5174 p->encode_coding_system 5163 p->encode_coding_system
5175 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); 5164 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil);
5176 setup_coding_system (p->encode_coding_system, 5165 setup_coding_system (p->encode_coding_system,
5177 proc_encode_coding_system[XINT (p->outfd)]); 5166 proc_encode_coding_system[p->outfd]);
5178 } 5167 }
5179 } 5168 }
5180 5169
@@ -5184,10 +5173,10 @@ read_process_output (proc, channel)
5184 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5173 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5185 bcopy (coding->carryover, SDATA (p->decoding_buf), 5174 bcopy (coding->carryover, SDATA (p->decoding_buf),
5186 coding->carryover_bytes); 5175 coding->carryover_bytes);
5187 XSETINT (p->decoding_carryover, coding->carryover_bytes); 5176 p->decoding_carryover = coding->carryover_bytes;
5188 } 5177 }
5189 /* Adjust the multibyteness of TEXT to that of the filter. */ 5178 /* Adjust the multibyteness of TEXT to that of the filter. */
5190 if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text)) 5179 if (p->filter_multibyte != STRING_MULTIBYTE (text))
5191 text = (STRING_MULTIBYTE (text) 5180 text = (STRING_MULTIBYTE (text)
5192 ? Fstring_as_unibyte (text) 5181 ? Fstring_as_unibyte (text)
5193 : Fstring_to_multibyte (text)); 5182 : Fstring_to_multibyte (text));
@@ -5279,12 +5268,12 @@ read_process_output (proc, channel)
5279 { 5268 {
5280 p->decode_coding_system = Vlast_coding_system_used; 5269 p->decode_coding_system = Vlast_coding_system_used;
5281 if (NILP (p->encode_coding_system) 5270 if (NILP (p->encode_coding_system)
5282 && proc_encode_coding_system[XINT (p->outfd)]) 5271 && proc_encode_coding_system[p->outfd])
5283 { 5272 {
5284 p->encode_coding_system 5273 p->encode_coding_system
5285 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); 5274 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil);
5286 setup_coding_system (p->encode_coding_system, 5275 setup_coding_system (p->encode_coding_system,
5287 proc_encode_coding_system[XINT (p->outfd)]); 5276 proc_encode_coding_system[p->outfd]);
5288 } 5277 }
5289 } 5278 }
5290 if (coding->carryover_bytes > 0) 5279 if (coding->carryover_bytes > 0)
@@ -5293,7 +5282,7 @@ read_process_output (proc, channel)
5293 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5282 p->decoding_buf = make_uninit_string (coding->carryover_bytes);
5294 bcopy (coding->carryover, SDATA (p->decoding_buf), 5283 bcopy (coding->carryover, SDATA (p->decoding_buf),
5295 coding->carryover_bytes); 5284 coding->carryover_bytes);
5296 XSETINT (p->decoding_carryover, coding->carryover_bytes); 5285 p->decoding_carryover = coding->carryover_bytes;
5297 } 5286 }
5298 /* Adjust the multibyteness of TEXT to that of the buffer. */ 5287 /* Adjust the multibyteness of TEXT to that of the buffer. */
5299 if (NILP (current_buffer->enable_multibyte_characters) 5288 if (NILP (current_buffer->enable_multibyte_characters)
@@ -5412,10 +5401,10 @@ send_process (proc, buf, len, object)
5412 update_status (p); 5401 update_status (p);
5413 if (! EQ (p->status, Qrun)) 5402 if (! EQ (p->status, Qrun))
5414 error ("Process %s not running", SDATA (p->name)); 5403 error ("Process %s not running", SDATA (p->name));
5415 if (XINT (p->outfd) < 0) 5404 if (p->outfd < 0)
5416 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5405 error ("Output file descriptor of %s is closed", SDATA (p->name));
5417 5406
5418 coding = proc_encode_coding_system[XINT (p->outfd)]; 5407 coding = proc_encode_coding_system[p->outfd];
5419 Vlast_coding_system_used = CODING_ID_NAME (coding->id); 5408 Vlast_coding_system_used = CODING_ID_NAME (coding->id);
5420 5409
5421 if ((STRINGP (object) && STRING_MULTIBYTE (object)) 5410 if ((STRINGP (object) && STRING_MULTIBYTE (object))
@@ -5499,7 +5488,7 @@ send_process (proc, buf, len, object)
5499 if (pty_max_bytes == 0) 5488 if (pty_max_bytes == 0)
5500 { 5489 {
5501#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) 5490#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
5502 pty_max_bytes = fpathconf (XFASTINT (p->outfd), _PC_MAX_CANON); 5491 pty_max_bytes = fpathconf (p->outfd, _PC_MAX_CANON);
5503 if (pty_max_bytes < 0) 5492 if (pty_max_bytes < 0)
5504 pty_max_bytes = 250; 5493 pty_max_bytes = 250;
5505#else 5494#else
@@ -5521,7 +5510,7 @@ send_process (proc, buf, len, object)
5521 5510
5522 /* Decide how much data we can send in one batch. 5511 /* Decide how much data we can send in one batch.
5523 Long lines need to be split into multiple batches. */ 5512 Long lines need to be split into multiple batches. */
5524 if (!NILP (p->pty_flag)) 5513 if (p->pty_flag)
5525 { 5514 {
5526 /* Starting this at zero is always correct when not the first 5515 /* Starting this at zero is always correct when not the first
5527 iteration because the previous iteration ended by sending C-d. 5516 iteration because the previous iteration ended by sending C-d.
@@ -5550,7 +5539,7 @@ send_process (proc, buf, len, object)
5550 /* Send this batch, using one or more write calls. */ 5539 /* Send this batch, using one or more write calls. */
5551 while (this > 0) 5540 while (this > 0)
5552 { 5541 {
5553 int outfd = XINT (p->outfd); 5542 int outfd = p->outfd;
5554 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); 5543 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap);
5555#ifdef DATAGRAM_SOCKETS 5544#ifdef DATAGRAM_SOCKETS
5556 if (DATAGRAM_CHAN_P (outfd)) 5545 if (DATAGRAM_CHAN_P (outfd))
@@ -5570,12 +5559,12 @@ send_process (proc, buf, len, object)
5570 { 5559 {
5571 rv = emacs_write (outfd, (char *) buf, this); 5560 rv = emacs_write (outfd, (char *) buf, this);
5572#ifdef ADAPTIVE_READ_BUFFERING 5561#ifdef ADAPTIVE_READ_BUFFERING
5573 if (XINT (p->read_output_delay) > 0 5562 if (p->read_output_delay > 0
5574 && EQ (p->adaptive_read_buffering, Qt)) 5563 && p->adaptive_read_buffering == 1)
5575 { 5564 {
5576 XSETFASTINT (p->read_output_delay, 0); 5565 p->read_output_delay = 0;
5577 process_output_delay_count--; 5566 process_output_delay_count--;
5578 p->read_output_skip = Qnil; 5567 p->read_output_skip = 0;
5579 } 5568 }
5580#endif 5569#endif
5581 } 5570 }
@@ -5618,7 +5607,7 @@ send_process (proc, buf, len, object)
5618 if (errno == EAGAIN) 5607 if (errno == EAGAIN)
5619 { 5608 {
5620 int flags = FWRITE; 5609 int flags = FWRITE;
5621 ioctl (XINT (p->outfd), TIOCFLUSH, &flags); 5610 ioctl (p->outfd, TIOCFLUSH, &flags);
5622 } 5611 }
5623#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ 5612#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
5624 5613
@@ -5667,7 +5656,7 @@ send_process (proc, buf, len, object)
5667#endif 5656#endif
5668 p->raw_status_new = 0; 5657 p->raw_status_new = 0;
5669 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5658 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil));
5670 XSETINT (p->tick, ++process_tick); 5659 p->tick = ++process_tick;
5671 deactivate_process (proc); 5660 deactivate_process (proc);
5672#ifdef VMS 5661#ifdef VMS
5673 error ("Error writing to process %s; closed it", SDATA (p->name)); 5662 error ("Error writing to process %s; closed it", SDATA (p->name));
@@ -5736,7 +5725,7 @@ emacs_get_tty_pgrp (p)
5736 int gid = -1; 5725 int gid = -1;
5737 5726
5738#ifdef TIOCGPGRP 5727#ifdef TIOCGPGRP
5739 if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) 5728 if (ioctl (p->infd, TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name))
5740 { 5729 {
5741 int fd; 5730 int fd;
5742 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the 5731 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the
@@ -5774,7 +5763,7 @@ return t unconditionally. */)
5774 if (!EQ (p->childp, Qt)) 5763 if (!EQ (p->childp, Qt))
5775 error ("Process %s is not a subprocess", 5764 error ("Process %s is not a subprocess",
5776 SDATA (p->name)); 5765 SDATA (p->name));
5777 if (XINT (p->infd) < 0) 5766 if (p->infd < 0)
5778 error ("Process %s is not active", 5767 error ("Process %s is not active",
5779 SDATA (p->name)); 5768 SDATA (p->name));
5780 5769
@@ -5817,11 +5806,11 @@ process_send_signal (process, signo, current_group, nomsg)
5817 if (!EQ (p->childp, Qt)) 5806 if (!EQ (p->childp, Qt))
5818 error ("Process %s is not a subprocess", 5807 error ("Process %s is not a subprocess",
5819 SDATA (p->name)); 5808 SDATA (p->name));
5820 if (XINT (p->infd) < 0) 5809 if (p->infd < 0)
5821 error ("Process %s is not active", 5810 error ("Process %s is not active",
5822 SDATA (p->name)); 5811 SDATA (p->name));
5823 5812
5824 if (NILP (p->pty_flag)) 5813 if (!p->pty_flag)
5825 current_group = Qnil; 5814 current_group = Qnil;
5826 5815
5827 /* If we are using pgrps, get a pgrp number and make it negative. */ 5816 /* If we are using pgrps, get a pgrp number and make it negative. */
@@ -5840,7 +5829,7 @@ process_send_signal (process, signo, current_group, nomsg)
5840 struct termios t; 5829 struct termios t;
5841 cc_t *sig_char = NULL; 5830 cc_t *sig_char = NULL;
5842 5831
5843 tcgetattr (XINT (p->infd), &t); 5832 tcgetattr (p->infd, &t);
5844 5833
5845 switch (signo) 5834 switch (signo)
5846 { 5835 {
@@ -5880,16 +5869,16 @@ process_send_signal (process, signo, current_group, nomsg)
5880 switch (signo) 5869 switch (signo)
5881 { 5870 {
5882 case SIGINT: 5871 case SIGINT:
5883 ioctl (XINT (p->infd), TIOCGETC, &c); 5872 ioctl (p->infd, TIOCGETC, &c);
5884 send_process (proc, &c.t_intrc, 1, Qnil); 5873 send_process (proc, &c.t_intrc, 1, Qnil);
5885 return; 5874 return;
5886 case SIGQUIT: 5875 case SIGQUIT:
5887 ioctl (XINT (p->infd), TIOCGETC, &c); 5876 ioctl (p->infd, TIOCGETC, &c);
5888 send_process (proc, &c.t_quitc, 1, Qnil); 5877 send_process (proc, &c.t_quitc, 1, Qnil);
5889 return; 5878 return;
5890#ifdef SIGTSTP 5879#ifdef SIGTSTP
5891 case SIGTSTP: 5880 case SIGTSTP:
5892 ioctl (XINT (p->infd), TIOCGLTC, &lc); 5881 ioctl (p->infd, TIOCGLTC, &lc);
5893 send_process (proc, &lc.t_suspc, 1, Qnil); 5882 send_process (proc, &lc.t_suspc, 1, Qnil);
5894 return; 5883 return;
5895#endif /* ! defined (SIGTSTP) */ 5884#endif /* ! defined (SIGTSTP) */
@@ -5904,16 +5893,16 @@ process_send_signal (process, signo, current_group, nomsg)
5904 switch (signo) 5893 switch (signo)
5905 { 5894 {
5906 case SIGINT: 5895 case SIGINT:
5907 ioctl (XINT (p->infd), TCGETA, &t); 5896 ioctl (p->infd, TCGETA, &t);
5908 send_process (proc, &t.c_cc[VINTR], 1, Qnil); 5897 send_process (proc, &t.c_cc[VINTR], 1, Qnil);
5909 return; 5898 return;
5910 case SIGQUIT: 5899 case SIGQUIT:
5911 ioctl (XINT (p->infd), TCGETA, &t); 5900 ioctl (p->infd, TCGETA, &t);
5912 send_process (proc, &t.c_cc[VQUIT], 1, Qnil); 5901 send_process (proc, &t.c_cc[VQUIT], 1, Qnil);
5913 return; 5902 return;
5914#ifdef SIGTSTP 5903#ifdef SIGTSTP
5915 case SIGTSTP: 5904 case SIGTSTP:
5916 ioctl (XINT (p->infd), TCGETA, &t); 5905 ioctl (p->infd, TCGETA, &t);
5917 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); 5906 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil);
5918 return; 5907 return;
5919#endif /* ! defined (SIGTSTP) */ 5908#endif /* ! defined (SIGTSTP) */
@@ -5971,7 +5960,7 @@ process_send_signal (process, signo, current_group, nomsg)
5971 case SIGCONT: 5960 case SIGCONT:
5972 p->raw_status_new = 0; 5961 p->raw_status_new = 0;
5973 p->status = Qrun; 5962 p->status = Qrun;
5974 XSETINT (p->tick, ++process_tick); 5963 p->tick = ++process_tick;
5975 if (!nomsg) 5964 if (!nomsg)
5976 status_notify (NULL); 5965 status_notify (NULL);
5977 break; 5966 break;
@@ -5991,7 +5980,7 @@ process_send_signal (process, signo, current_group, nomsg)
5991 sys$forcex (&(p->pid), 0, 1); 5980 sys$forcex (&(p->pid), 0, 1);
5992 whoosh: 5981 whoosh:
5993#endif 5982#endif
5994 flush_pending_output (XINT (p->infd)); 5983 flush_pending_output (p->infd);
5995 break; 5984 break;
5996 } 5985 }
5997 5986
@@ -6008,7 +5997,7 @@ process_send_signal (process, signo, current_group, nomsg)
6008#ifdef TIOCSIGSEND 5997#ifdef TIOCSIGSEND
6009 if (!NILP (current_group)) 5998 if (!NILP (current_group))
6010 { 5999 {
6011 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) 6000 if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
6012 EMACS_KILLPG (gid, signo); 6001 EMACS_KILLPG (gid, signo);
6013 } 6002 }
6014 else 6003 else
@@ -6074,10 +6063,10 @@ If PROCESS is a network process, inhibit handling of incoming traffic. */)
6074 6063
6075 p = XPROCESS (process); 6064 p = XPROCESS (process);
6076 if (NILP (p->command) 6065 if (NILP (p->command)
6077 && XINT (p->infd) >= 0) 6066 && p->infd >= 0)
6078 { 6067 {
6079 FD_CLR (XINT (p->infd), &input_wait_mask); 6068 FD_CLR (p->infd, &input_wait_mask);
6080 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6069 FD_CLR (p->infd, &non_keyboard_wait_mask);
6081 } 6070 }
6082 p->command = Qt; 6071 p->command = Qt;
6083 return process; 6072 return process;
@@ -6105,11 +6094,11 @@ If PROCESS is a network process, resume handling of incoming traffic. */)
6105 6094
6106 p = XPROCESS (process); 6095 p = XPROCESS (process);
6107 if (EQ (p->command, Qt) 6096 if (EQ (p->command, Qt)
6108 && XINT (p->infd) >= 0 6097 && p->infd >= 0
6109 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) 6098 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten)))
6110 { 6099 {
6111 FD_SET (XINT (p->infd), &input_wait_mask); 6100 FD_SET (p->infd, &input_wait_mask);
6112 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 6101 FD_SET (p->infd, &non_keyboard_wait_mask);
6113 } 6102 }
6114 p->command = Qnil; 6103 p->command = Qnil;
6115 return process; 6104 return process;
@@ -6306,7 +6295,7 @@ text to PROCESS after you call this function. */)
6306 return process; 6295 return process;
6307 6296
6308 proc = get_process (process); 6297 proc = get_process (process);
6309 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 6298 coding = proc_encode_coding_system[XPROCESS (proc)->outfd];
6310 6299
6311 /* Make sure the process is really alive. */ 6300 /* Make sure the process is really alive. */
6312 if (XPROCESS (proc)->raw_status_new) 6301 if (XPROCESS (proc)->raw_status_new)
@@ -6323,7 +6312,7 @@ text to PROCESS after you call this function. */)
6323#ifdef VMS 6312#ifdef VMS
6324 send_process (proc, "\032", 1, Qnil); /* ^z */ 6313 send_process (proc, "\032", 1, Qnil); /* ^z */
6325#else 6314#else
6326 if (!NILP (XPROCESS (proc)->pty_flag)) 6315 if (XPROCESS (proc)->pty_flag)
6327 send_process (proc, "\004", 1, Qnil); 6316 send_process (proc, "\004", 1, Qnil);
6328 else 6317 else
6329 { 6318 {
@@ -6335,18 +6324,18 @@ text to PROCESS after you call this function. */)
6335 (In some old system, shutdown to socketpair doesn't work. 6324 (In some old system, shutdown to socketpair doesn't work.
6336 Then we just can't win.) */ 6325 Then we just can't win.) */
6337 if (XPROCESS (proc)->pid == 0 6326 if (XPROCESS (proc)->pid == 0
6338 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) 6327 || XPROCESS (proc)->outfd == XPROCESS (proc)->infd)
6339 shutdown (XINT (XPROCESS (proc)->outfd), 1); 6328 shutdown (XPROCESS (proc)->outfd, 1);
6340 /* In case of socketpair, outfd == infd, so don't close it. */ 6329 /* In case of socketpair, outfd == infd, so don't close it. */
6341 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) 6330 if (XPROCESS (proc)->outfd != XPROCESS (proc)->infd)
6342 emacs_close (XINT (XPROCESS (proc)->outfd)); 6331 emacs_close (XPROCESS (proc)->outfd);
6343#else /* not HAVE_SHUTDOWN */ 6332#else /* not HAVE_SHUTDOWN */
6344 emacs_close (XINT (XPROCESS (proc)->outfd)); 6333 emacs_close (XPROCESS (proc)->outfd);
6345#endif /* not HAVE_SHUTDOWN */ 6334#endif /* not HAVE_SHUTDOWN */
6346 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); 6335 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
6347 if (new_outfd < 0) 6336 if (new_outfd < 0)
6348 abort (); 6337 abort ();
6349 old_outfd = XINT (XPROCESS (proc)->outfd); 6338 old_outfd = XPROCESS (proc)->outfd;
6350 6339
6351 if (!proc_encode_coding_system[new_outfd]) 6340 if (!proc_encode_coding_system[new_outfd])
6352 proc_encode_coding_system[new_outfd] 6341 proc_encode_coding_system[new_outfd]
@@ -6357,7 +6346,7 @@ text to PROCESS after you call this function. */)
6357 bzero (proc_encode_coding_system[old_outfd], 6346 bzero (proc_encode_coding_system[old_outfd],
6358 sizeof (struct coding_system)); 6347 sizeof (struct coding_system));
6359 6348
6360 XSETINT (XPROCESS (proc)->outfd, new_outfd); 6349 XPROCESS (proc)->outfd = new_outfd;
6361 } 6350 }
6362#endif /* VMS */ 6351#endif /* VMS */
6363 return process; 6352 return process;
@@ -6380,7 +6369,7 @@ kill_buffer_processes (buffer)
6380 { 6369 {
6381 if (NETCONN_P (proc)) 6370 if (NETCONN_P (proc))
6382 Fdelete_process (proc); 6371 Fdelete_process (proc);
6383 else if (XINT (XPROCESS (proc)->infd) >= 0) 6372 else if (XPROCESS (proc)->infd >= 0)
6384 process_send_signal (proc, SIGHUP, Qnil, 1); 6373 process_send_signal (proc, SIGHUP, Qnil, 1);
6385 } 6374 }
6386 } 6375 }
@@ -6510,21 +6499,21 @@ sigchld_handler (signo)
6510 union { int i; WAITTYPE wt; } u; 6499 union { int i; WAITTYPE wt; } u;
6511 int clear_desc_flag = 0; 6500 int clear_desc_flag = 0;
6512 6501
6513 XSETINT (p->tick, ++process_tick); 6502 p->tick = ++process_tick;
6514 u.wt = w; 6503 u.wt = w;
6515 p->raw_status = u.i; 6504 p->raw_status = u.i;
6516 p->raw_status_new = 1; 6505 p->raw_status_new = 1;
6517 6506
6518 /* If process has terminated, stop waiting for its output. */ 6507 /* If process has terminated, stop waiting for its output. */
6519 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6508 if ((WIFSIGNALED (w) || WIFEXITED (w))
6520 && XINT (p->infd) >= 0) 6509 && p->infd >= 0)
6521 clear_desc_flag = 1; 6510 clear_desc_flag = 1;
6522 6511
6523 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ 6512 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */
6524 if (clear_desc_flag) 6513 if (clear_desc_flag)
6525 { 6514 {
6526 FD_CLR (XINT (p->infd), &input_wait_mask); 6515 FD_CLR (p->infd, &input_wait_mask);
6527 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6516 FD_CLR (p->infd, &non_keyboard_wait_mask);
6528 } 6517 }
6529 6518
6530 /* Tell wait_reading_process_output that it needs to wake up and 6519 /* Tell wait_reading_process_output that it needs to wake up and
@@ -6701,18 +6690,18 @@ status_notify (deleting_process)
6701 proc = Fcdr (Fcar (tail)); 6690 proc = Fcdr (Fcar (tail));
6702 p = XPROCESS (proc); 6691 p = XPROCESS (proc);
6703 6692
6704 if (XINT (p->tick) != XINT (p->update_tick)) 6693 if (p->tick != p->update_tick)
6705 { 6694 {
6706 XSETINT (p->update_tick, XINT (p->tick)); 6695 p->update_tick = p->tick;
6707 6696
6708 /* If process is still active, read any output that remains. */ 6697 /* If process is still active, read any output that remains. */
6709 while (! EQ (p->filter, Qt) 6698 while (! EQ (p->filter, Qt)
6710 && ! EQ (p->status, Qconnect) 6699 && ! EQ (p->status, Qconnect)
6711 && ! EQ (p->status, Qlisten) 6700 && ! EQ (p->status, Qlisten)
6712 && ! EQ (p->command, Qt) /* Network process not stopped. */ 6701 && ! EQ (p->command, Qt) /* Network process not stopped. */
6713 && XINT (p->infd) >= 0 6702 && p->infd >= 0
6714 && p != deleting_process 6703 && p != deleting_process
6715 && read_process_output (proc, XINT (p->infd)) > 0); 6704 && read_process_output (proc, p->infd) > 0);
6716 6705
6717 buffer = p->buffer; 6706 buffer = p->buffer;
6718 6707
@@ -6739,7 +6728,7 @@ status_notify (deleting_process)
6739 So set p->update_tick again 6728 So set p->update_tick again
6740 so that an error in the sentinel will not cause 6729 so that an error in the sentinel will not cause
6741 this code to be run again. */ 6730 this code to be run again. */
6742 XSETINT (p->update_tick, XINT (p->tick)); 6731 p->update_tick = p->tick;
6743 /* Now output the message suitably. */ 6732 /* Now output the message suitably. */
6744 if (!NILP (p->sentinel)) 6733 if (!NILP (p->sentinel))
6745 exec_sentinel (proc, msg); 6734 exec_sentinel (proc, msg);
@@ -6812,9 +6801,9 @@ encode subprocess input. */)
6812 6801
6813 CHECK_PROCESS (process); 6802 CHECK_PROCESS (process);
6814 p = XPROCESS (process); 6803 p = XPROCESS (process);
6815 if (XINT (p->infd) < 0) 6804 if (p->infd < 0)
6816 error ("Input file descriptor of %s closed", SDATA (p->name)); 6805 error ("Input file descriptor of %s closed", SDATA (p->name));
6817 if (XINT (p->outfd) < 0) 6806 if (p->outfd < 0)
6818 error ("Output file descriptor of %s closed", SDATA (p->name)); 6807 error ("Output file descriptor of %s closed", SDATA (p->name));
6819 Fcheck_coding_system (decoding); 6808 Fcheck_coding_system (decoding);
6820 Fcheck_coding_system (encoding); 6809 Fcheck_coding_system (encoding);
@@ -6851,7 +6840,7 @@ suppressed. */)
6851 6840
6852 CHECK_PROCESS (process); 6841 CHECK_PROCESS (process);
6853 p = XPROCESS (process); 6842 p = XPROCESS (process);
6854 p->filter_multibyte = flag; 6843 p->filter_multibyte = !NILP (flag);
6855 setup_process_coding_systems (process); 6844 setup_process_coding_systems (process);
6856 6845
6857 return Qnil; 6846 return Qnil;
@@ -6868,7 +6857,7 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6868 CHECK_PROCESS (process); 6857 CHECK_PROCESS (process);
6869 p = XPROCESS (process); 6858 p = XPROCESS (process);
6870 6859
6871 return (NILP (p->filter_multibyte) ? Qnil : Qt); 6860 return (p->filter_multibyte ? Qt : Qnil);
6872} 6861}
6873 6862
6874 6863