aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2007-07-12 06:36:57 +0000
committerStefan Monnier2007-07-12 06:36:57 +0000
commit60f0fb11dda9422e50dd58fb1e4dff76a960a107 (patch)
tree1e44eca65913d145dff7370923e8b2034758fba5 /src
parentd1947d4c8f91b75bde4e57323d57098e321d60fa (diff)
downloademacs-60f0fb11dda9422e50dd58fb1e4dff76a960a107.tar.gz
emacs-60f0fb11dda9422e50dd58fb1e4dff76a960a107.zip
(struct Lisp_Process): Turn slots infd, outfd, kill_without_query, pty_flag,
tick, update_tick, decoding_carryover, inherit_coding_system_flag, filter_multibyte, adaptive_read_buffering, read_output_delay, and read_output_skip from Lisp_Objects to ints. Remove unused encoding_carryover.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/process.c303
-rw-r--r--src/process.h76
3 files changed, 197 insertions, 191 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e920eb57437..80871a10449 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12007-07-12 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * process.h (struct Lisp_Process): Turn slots infd, outfd,
4 kill_without_query, pty_flag, tick, update_tick, decoding_carryover,
5 inherit_coding_system_flag, filter_multibyte, adaptive_read_buffering,
6 read_output_delay, and read_output_skip from Lisp_Objects to ints.
7 Remove unused encoding_carryover.
8 * process.c: Adjust all functions accordingly.
9
12007-07-12 Richard Stallman <rms@gnu.org> 102007-07-12 Richard Stallman <rms@gnu.org>
2 11
3 * term.c: Include unistd.h only if HAVE_UNISTD_H. 12 * term.c: Include unistd.h only if HAVE_UNISTD_H.
diff --git a/src/process.c b/src/process.c
index c248a8144db..90d0ee34024 100644
--- a/src/process.c
+++ b/src/process.c
@@ -393,7 +393,7 @@ struct sockaddr_and_len {
393 int len; 393 int len;
394} datagram_address[MAXDESC]; 394} datagram_address[MAXDESC];
395#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0) 395#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) 396#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0)
397#else 397#else
398#define DATAGRAM_CHAN_P(chan) (0) 398#define DATAGRAM_CHAN_P(chan) (0)
399#define DATAGRAM_CONN_P(proc) (0) 399#define DATAGRAM_CONN_P(proc) (0)
@@ -628,19 +628,19 @@ make_process (name)
628 628
629 p = allocate_process (); 629 p = allocate_process ();
630 630
631 XSETINT (p->infd, -1); 631 p->infd = -1;
632 XSETINT (p->outfd, -1); 632 p->outfd = -1;
633 XSETFASTINT (p->tick, 0); 633 p->tick = 0;
634 XSETFASTINT (p->update_tick, 0); 634 p->update_tick = 0;
635 p->pid = 0; 635 p->pid = 0;
636 p->raw_status_new = 0; 636 p->raw_status_new = 0;
637 p->status = Qrun; 637 p->status = Qrun;
638 p->mark = Fmake_marker (); 638 p->mark = Fmake_marker ();
639 639
640#ifdef ADAPTIVE_READ_BUFFERING 640#ifdef ADAPTIVE_READ_BUFFERING
641 p->adaptive_read_buffering = Qnil; 641 p->adaptive_read_buffering = 0;
642 XSETFASTINT (p->read_output_delay, 0); 642 p->read_output_delay = 0;
643 p->read_output_skip = Qnil; 643 p->read_output_skip = 0;
644#endif 644#endif
645 645
646 /* If name is already in use, modify it until it is unused. */ 646 /* If name is already in use, modify it until it is unused. */
@@ -679,8 +679,8 @@ setup_process_coding_systems (process)
679 Lisp_Object process; 679 Lisp_Object process;
680{ 680{
681 struct Lisp_Process *p = XPROCESS (process); 681 struct Lisp_Process *p = XPROCESS (process);
682 int inch = XINT (p->infd); 682 int inch = p->infd;
683 int outch = XINT (p->outfd); 683 int outch = p->outfd;
684 684
685 if (inch < 0 || outch < 0) 685 if (inch < 0 || outch < 0)
686 return; 686 return;
@@ -692,7 +692,7 @@ setup_process_coding_systems (process)
692 proc_decode_coding_system[inch]); 692 proc_decode_coding_system[inch]);
693 if (! NILP (p->filter)) 693 if (! NILP (p->filter))
694 { 694 {
695 if (NILP (p->filter_multibyte)) 695 if (!p->filter_multibyte)
696 setup_raw_text_coding_system (proc_decode_coding_system[inch]); 696 setup_raw_text_coding_system (proc_decode_coding_system[inch]);
697 } 697 }
698 else if (BUFFERP (p->buffer)) 698 else if (BUFFERP (p->buffer))
@@ -815,10 +815,10 @@ nil, indicating the current buffer's process. */)
815 if (NETCONN1_P (p)) 815 if (NETCONN1_P (p))
816 { 816 {
817 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 817 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
818 XSETINT (p->tick, ++process_tick); 818 p->tick = ++process_tick;
819 status_notify (p); 819 status_notify (p);
820 } 820 }
821 else if (XINT (p->infd) >= 0) 821 else if (p->infd >= 0)
822 { 822 {
823#ifdef SIGCHLD 823#ifdef SIGCHLD
824 Lisp_Object symbol; 824 Lisp_Object symbol;
@@ -846,7 +846,7 @@ nil, indicating the current buffer's process. */)
846 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 846 /* Do this now, since remove_process will make sigchld_handler do nothing. */
847 p->status 847 p->status
848 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); 848 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil));
849 XSETINT (p->tick, ++process_tick); 849 p->tick = ++process_tick;
850 status_notify (p); 850 status_notify (p);
851 } 851 }
852 } 852 }
@@ -1038,18 +1038,18 @@ The string argument is normally a multibyte string, except:
1038 (debug) 1038 (debug)
1039 (set-process-filter process ...) */ 1039 (set-process-filter process ...) */
1040 1040
1041 if (XINT (p->infd) >= 0) 1041 if (p->infd >= 0)
1042 { 1042 {
1043 if (EQ (filter, Qt) && !EQ (p->status, Qlisten)) 1043 if (EQ (filter, Qt) && !EQ (p->status, Qlisten))
1044 { 1044 {
1045 FD_CLR (XINT (p->infd), &input_wait_mask); 1045 FD_CLR (p->infd, &input_wait_mask);
1046 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 1046 FD_CLR (p->infd, &non_keyboard_wait_mask);
1047 } 1047 }
1048 else if (EQ (p->filter, Qt) 1048 else if (EQ (p->filter, Qt)
1049 && !EQ (p->command, Qt)) /* Network process not stopped. */ 1049 && !EQ (p->command, Qt)) /* Network process not stopped. */
1050 { 1050 {
1051 FD_SET (XINT (p->infd), &input_wait_mask); 1051 FD_SET (p->infd, &input_wait_mask);
1052 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 1052 FD_SET (p->infd, &non_keyboard_wait_mask);
1053 } 1053 }
1054 } 1054 }
1055 1055
@@ -1111,8 +1111,8 @@ DEFUN ("set-process-window-size", Fset_process_window_size,
1111 CHECK_NATNUM (height); 1111 CHECK_NATNUM (height);
1112 CHECK_NATNUM (width); 1112 CHECK_NATNUM (width);
1113 1113
1114 if (XINT (XPROCESS (process)->infd) < 0 1114 if (XPROCESS (process)->infd < 0
1115 || set_window_size (XINT (XPROCESS (process)->infd), 1115 || set_window_size (XPROCESS (process)->infd,
1116 XINT (height), XINT (width)) <= 0) 1116 XINT (height), XINT (width)) <= 0)
1117 return Qnil; 1117 return Qnil;
1118 else 1118 else
@@ -1140,7 +1140,7 @@ for the process which will run. */)
1140 register Lisp_Object process, flag; 1140 register Lisp_Object process, flag;
1141{ 1141{
1142 CHECK_PROCESS (process); 1142 CHECK_PROCESS (process);
1143 XPROCESS (process)->inherit_coding_system_flag = flag; 1143 XPROCESS (process)->inherit_coding_system_flag = !NILP (flag);
1144 return flag; 1144 return flag;
1145} 1145}
1146 1146
@@ -1155,7 +1155,7 @@ the process output. */)
1155 register Lisp_Object process; 1155 register Lisp_Object process;
1156{ 1156{
1157 CHECK_PROCESS (process); 1157 CHECK_PROCESS (process);
1158 return XPROCESS (process)->inherit_coding_system_flag; 1158 return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil;
1159} 1159}
1160 1160
1161DEFUN ("set-process-query-on-exit-flag", 1161DEFUN ("set-process-query-on-exit-flag",
@@ -1168,7 +1168,7 @@ exiting if PROCESS is running. */)
1168 register Lisp_Object process, flag; 1168 register Lisp_Object process, flag;
1169{ 1169{
1170 CHECK_PROCESS (process); 1170 CHECK_PROCESS (process);
1171 XPROCESS (process)->kill_without_query = Fnull (flag); 1171 XPROCESS (process)->kill_without_query = NILP (flag);
1172 return flag; 1172 return flag;
1173} 1173}
1174 1174
@@ -1180,7 +1180,7 @@ DEFUN ("process-query-on-exit-flag",
1180 register Lisp_Object process; 1180 register Lisp_Object process;
1181{ 1181{
1182 CHECK_PROCESS (process); 1182 CHECK_PROCESS (process);
1183 return Fnull (XPROCESS (process)->kill_without_query); 1183 return (XPROCESS (process)->kill_without_query ? Qnil : Qt);
1184} 1184}
1185 1185
1186#ifdef DATAGRAM_SOCKETS 1186#ifdef DATAGRAM_SOCKETS
@@ -1355,7 +1355,7 @@ list_processes_1 (query_only)
1355 p = XPROCESS (proc); 1355 p = XPROCESS (proc);
1356 if (NILP (p->childp)) 1356 if (NILP (p->childp))
1357 continue; 1357 continue;
1358 if (!NILP (query_only) && !NILP (p->kill_without_query)) 1358 if (!NILP (query_only) && p->kill_without_query)
1359 continue; 1359 continue;
1360 if (STRINGP (p->name) 1360 if (STRINGP (p->name)
1361 && ( i = SCHARS (p->name), (i > w_proc))) 1361 && ( i = SCHARS (p->name), (i > w_proc)))
@@ -1418,7 +1418,7 @@ list_processes_1 (query_only)
1418 p = XPROCESS (proc); 1418 p = XPROCESS (proc);
1419 if (NILP (p->childp)) 1419 if (NILP (p->childp))
1420 continue; 1420 continue;
1421 if (!NILP (query_only) && !NILP (p->kill_without_query)) 1421 if (!NILP (query_only) && p->kill_without_query)
1422 continue; 1422 continue;
1423 1423
1424 Finsert (1, &p->name); 1424 Finsert (1, &p->name);
@@ -1494,7 +1494,7 @@ list_processes_1 (query_only)
1494 if (NILP (port)) 1494 if (NILP (port))
1495 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); 1495 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil);
1496 sprintf (tembuf, "(network %s server on %s)\n", 1496 sprintf (tembuf, "(network %s server on %s)\n",
1497 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1497 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1498 (STRINGP (port) ? (char *)SDATA (port) : "?")); 1498 (STRINGP (port) ? (char *)SDATA (port) : "?"));
1499 insert_string (tembuf); 1499 insert_string (tembuf);
1500 } 1500 }
@@ -1512,7 +1512,7 @@ list_processes_1 (query_only)
1512 if (NILP (host)) 1512 if (NILP (host))
1513 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); 1513 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil);
1514 sprintf (tembuf, "(network %s connection to %s)\n", 1514 sprintf (tembuf, "(network %s connection to %s)\n",
1515 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1515 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1516 (STRINGP (host) ? (char *)SDATA (host) : "?")); 1516 (STRINGP (host) ? (char *)SDATA (host) : "?"));
1517 insert_string (tembuf); 1517 insert_string (tembuf);
1518 } 1518 }
@@ -1643,11 +1643,13 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1643 XPROCESS (proc)->sentinel = Qnil; 1643 XPROCESS (proc)->sentinel = Qnil;
1644 XPROCESS (proc)->filter = Qnil; 1644 XPROCESS (proc)->filter = Qnil;
1645 XPROCESS (proc)->filter_multibyte 1645 XPROCESS (proc)->filter_multibyte
1646 = buffer_defaults.enable_multibyte_characters; 1646 = !NILP (buffer_defaults.enable_multibyte_characters);
1647 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1647 XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1648 1648
1649#ifdef ADAPTIVE_READ_BUFFERING 1649#ifdef ADAPTIVE_READ_BUFFERING
1650 XPROCESS (proc)->adaptive_read_buffering = Vprocess_adaptive_read_buffering; 1650 XPROCESS (proc)->adaptive_read_buffering
1651 = (NILP (Vprocess_adaptive_read_buffering) ? 0
1652 : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2);
1651#endif 1653#endif
1652 1654
1653 /* Make the process marker point into the process buffer (if any). */ 1655 /* Make the process marker point into the process buffer (if any). */
@@ -1778,13 +1780,11 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1778#endif /* not VMS */ 1780#endif /* not VMS */
1779 1781
1780 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 1782 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
1781 XPROCESS (proc)->decoding_carryover = make_number (0); 1783 XPROCESS (proc)->decoding_carryover = 0;
1782 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 1784 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
1783 XPROCESS (proc)->encoding_carryover = make_number (0);
1784 1785
1785 XPROCESS (proc)->inherit_coding_system_flag 1786 XPROCESS (proc)->inherit_coding_system_flag
1786 = (NILP (buffer) || !inherit_process_coding_system 1787 = (NILP (buffer) || !inherit_process_coding_system);
1787 ? Qnil : Qt);
1788 1788
1789 create_process (proc, (char **) new_argv, current_dir); 1789 create_process (proc, (char **) new_argv, current_dir);
1790 1790
@@ -1956,15 +1956,15 @@ create_process (process, new_argv, current_dir)
1956 /* Record this as an active process, with its channels. 1956 /* Record this as an active process, with its channels.
1957 As a result, child_setup will close Emacs's side of the pipes. */ 1957 As a result, child_setup will close Emacs's side of the pipes. */
1958 chan_process[inchannel] = process; 1958 chan_process[inchannel] = process;
1959 XSETINT (XPROCESS (process)->infd, inchannel); 1959 XPROCESS (process)->infd = inchannel;
1960 XSETINT (XPROCESS (process)->outfd, outchannel); 1960 XPROCESS (process)->outfd = outchannel;
1961 1961
1962 /* Previously we recorded the tty descriptor used in the subprocess. 1962 /* Previously we recorded the tty descriptor used in the subprocess.
1963 It was only used for getting the foreground tty process, so now 1963 It was only used for getting the foreground tty process, so now
1964 we just reopen the device (see emacs_get_tty_pgrp) as this is 1964 we just reopen the device (see emacs_get_tty_pgrp) as this is
1965 more portable (see USG_SUBTTY_WORKS above). */ 1965 more portable (see USG_SUBTTY_WORKS above). */
1966 1966
1967 XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); 1967 XPROCESS (process)->pty_flag = pty_flag;
1968 XPROCESS (process)->status = Qrun; 1968 XPROCESS (process)->status = Qrun;
1969 setup_process_coding_systems (process); 1969 setup_process_coding_systems (process);
1970 1970
@@ -2481,7 +2481,7 @@ DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_
2481 if (!DATAGRAM_CONN_P (process)) 2481 if (!DATAGRAM_CONN_P (process))
2482 return Qnil; 2482 return Qnil;
2483 2483
2484 channel = XINT (XPROCESS (process)->infd); 2484 channel = XPROCESS (process)->infd;
2485 return conv_sockaddr_to_lisp (datagram_address[channel].sa, 2485 return conv_sockaddr_to_lisp (datagram_address[channel].sa,
2486 datagram_address[channel].len); 2486 datagram_address[channel].len);
2487} 2487}
@@ -2501,7 +2501,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */)
2501 if (!DATAGRAM_CONN_P (process)) 2501 if (!DATAGRAM_CONN_P (process))
2502 return Qnil; 2502 return Qnil;
2503 2503
2504 channel = XINT (XPROCESS (process)->infd); 2504 channel = XPROCESS (process)->infd;
2505 2505
2506 len = get_lisp_to_sockaddr_size (address, &family); 2506 len = get_lisp_to_sockaddr_size (address, &family);
2507 if (datagram_address[channel].len != len) 2507 if (datagram_address[channel].len != len)
@@ -2666,7 +2666,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */)
2666 if (!NETCONN1_P (p)) 2666 if (!NETCONN1_P (p))
2667 error ("Process is not a network process"); 2667 error ("Process is not a network process");
2668 2668
2669 s = XINT (p->infd); 2669 s = p->infd;
2670 if (s < 0) 2670 if (s < 0)
2671 error ("Process is not running"); 2671 error ("Process is not running");
2672 2672
@@ -3420,18 +3420,18 @@ usage: (make-network-process &rest ARGS) */)
3420 p->buffer = buffer; 3420 p->buffer = buffer;
3421 p->sentinel = sentinel; 3421 p->sentinel = sentinel;
3422 p->filter = filter; 3422 p->filter = filter;
3423 p->filter_multibyte = buffer_defaults.enable_multibyte_characters; 3423 p->filter_multibyte = !NILP (buffer_defaults.enable_multibyte_characters);
3424 /* Override the above only if :filter-multibyte is specified. */ 3424 /* Override the above only if :filter-multibyte is specified. */
3425 if (! NILP (Fplist_member (contact, QCfilter_multibyte))) 3425 if (! NILP (Fplist_member (contact, QCfilter_multibyte)))
3426 p->filter_multibyte = Fplist_get (contact, QCfilter_multibyte); 3426 p->filter_multibyte = !NILP (Fplist_get (contact, QCfilter_multibyte));
3427 p->log = Fplist_get (contact, QClog); 3427 p->log = Fplist_get (contact, QClog);
3428 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 3428 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3429 p->kill_without_query = Qt; 3429 p->kill_without_query = 1;
3430 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) 3430 if ((tem = Fplist_get (contact, QCstop), !NILP (tem)))
3431 p->command = Qt; 3431 p->command = Qt;
3432 p->pid = 0; 3432 p->pid = 0;
3433 XSETINT (p->infd, inch); 3433 p->infd = inch;
3434 XSETINT (p->outfd, outch); 3434 p->outfd = outch;
3435 if (is_server && socktype == SOCK_STREAM) 3435 if (is_server && socktype == SOCK_STREAM)
3436 p->status = Qlisten; 3436 p->status = Qlisten;
3437 3437
@@ -3552,13 +3552,11 @@ usage: (make-network-process &rest ARGS) */)
3552 setup_process_coding_systems (proc); 3552 setup_process_coding_systems (proc);
3553 3553
3554 p->decoding_buf = make_uninit_string (0); 3554 p->decoding_buf = make_uninit_string (0);
3555 p->decoding_carryover = make_number (0); 3555 p->decoding_carryover = 0;
3556 p->encoding_buf = make_uninit_string (0); 3556 p->encoding_buf = make_uninit_string (0);
3557 p->encoding_carryover = make_number (0);
3558 3557
3559 p->inherit_coding_system_flag 3558 p->inherit_coding_system_flag
3560 = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system 3559 = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
3561 ? Qnil : Qt);
3562 3560
3563 UNGCPRO; 3561 UNGCPRO;
3564 return proc; 3562 return proc;
@@ -3821,16 +3819,16 @@ deactivate_process (proc)
3821 register int inchannel, outchannel; 3819 register int inchannel, outchannel;
3822 register struct Lisp_Process *p = XPROCESS (proc); 3820 register struct Lisp_Process *p = XPROCESS (proc);
3823 3821
3824 inchannel = XINT (p->infd); 3822 inchannel = p->infd;
3825 outchannel = XINT (p->outfd); 3823 outchannel = p->outfd;
3826 3824
3827#ifdef ADAPTIVE_READ_BUFFERING 3825#ifdef ADAPTIVE_READ_BUFFERING
3828 if (XINT (p->read_output_delay) > 0) 3826 if (p->read_output_delay > 0)
3829 { 3827 {
3830 if (--process_output_delay_count < 0) 3828 if (--process_output_delay_count < 0)
3831 process_output_delay_count = 0; 3829 process_output_delay_count = 0;
3832 XSETINT (p->read_output_delay, 0); 3830 p->read_output_delay = 0;
3833 p->read_output_skip = Qnil; 3831 p->read_output_skip = 0;
3834 } 3832 }
3835#endif 3833#endif
3836 3834
@@ -3852,8 +3850,8 @@ deactivate_process (proc)
3852 emacs_close (outchannel); 3850 emacs_close (outchannel);
3853#endif 3851#endif
3854 3852
3855 XSETINT (p->infd, -1); 3853 p->infd = -1;
3856 XSETINT (p->outfd, -1); 3854 p->outfd = -1;
3857#ifdef DATAGRAM_SOCKETS 3855#ifdef DATAGRAM_SOCKETS
3858 if (DATAGRAM_CHAN_P (inchannel)) 3856 if (DATAGRAM_CHAN_P (inchannel))
3859 { 3857 {
@@ -3901,8 +3899,8 @@ close_process_descs ()
3901 process = chan_process[i]; 3899 process = chan_process[i];
3902 if (!NILP (process)) 3900 if (!NILP (process))
3903 { 3901 {
3904 int in = XINT (XPROCESS (process)->infd); 3902 int in = XPROCESS (process)->infd;
3905 int out = XINT (XPROCESS (process)->outfd); 3903 int out = XPROCESS (process)->outfd;
3906 if (in >= 0) 3904 if (in >= 0)
3907 emacs_close (in); 3905 emacs_close (in);
3908 if (out >= 0 && in != out) 3906 if (out >= 0 && in != out)
@@ -4146,8 +4144,8 @@ server_accept_connection (server, channel)
4146 p->filter = ps->filter; 4144 p->filter = ps->filter;
4147 p->command = Qnil; 4145 p->command = Qnil;
4148 p->pid = 0; 4146 p->pid = 0;
4149 XSETINT (p->infd, s); 4147 p->infd = s;
4150 XSETINT (p->outfd, s); 4148 p->outfd = s;
4151 p->status = Qrun; 4149 p->status = Qrun;
4152 4150
4153 /* Client processes for accepted connections are not stopped initially. */ 4151 /* Client processes for accepted connections are not stopped initially. */
@@ -4170,12 +4168,11 @@ server_accept_connection (server, channel)
4170 setup_process_coding_systems (proc); 4168 setup_process_coding_systems (proc);
4171 4169
4172 p->decoding_buf = make_uninit_string (0); 4170 p->decoding_buf = make_uninit_string (0);
4173 p->decoding_carryover = make_number (0); 4171 p->decoding_carryover = 0;
4174 p->encoding_buf = make_uninit_string (0); 4172 p->encoding_buf = make_uninit_string (0);
4175 p->encoding_carryover = make_number (0);
4176 4173
4177 p->inherit_coding_system_flag 4174 p->inherit_coding_system_flag
4178 = (NILP (buffer) ? Qnil : ps->inherit_coding_system_flag); 4175 = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag);
4179 4176
4180 if (!NILP (ps->log)) 4177 if (!NILP (ps->log))
4181 call3 (ps->log, server, proc, 4178 call3 (ps->log, server, proc,
@@ -4300,7 +4297,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4300 4297
4301 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4298 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4302 if (wait_proc != NULL) 4299 if (wait_proc != NULL)
4303 wait_channel = XINT (wait_proc->infd); 4300 wait_channel = wait_proc->infd;
4304 4301
4305 record_unwind_protect (wait_reading_process_output_unwind, 4302 record_unwind_protect (wait_reading_process_output_unwind,
4306 make_number (waiting_for_user_input_p)); 4303 make_number (waiting_for_user_input_p));
@@ -4485,9 +4482,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4485 XSETPROCESS (proc, wait_proc); 4482 XSETPROCESS (proc, wait_proc);
4486 4483
4487 /* Read data from the process, until we exhaust it. */ 4484 /* Read data from the process, until we exhaust it. */
4488 while (XINT (wait_proc->infd) >= 0) 4485 while (wait_proc->infd >= 0)
4489 { 4486 {
4490 nread = read_process_output (proc, XINT (wait_proc->infd)); 4487 nread = read_process_output (proc, wait_proc->infd);
4491 4488
4492 if (nread == 0) 4489 if (nread == 0)
4493 break; 4490 break;
@@ -4517,9 +4514,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4517 4514
4518 if (wait_proc && just_wait_proc) 4515 if (wait_proc && just_wait_proc)
4519 { 4516 {
4520 if (XINT (wait_proc->infd) < 0) /* Terminated */ 4517 if (wait_proc->infd < 0) /* Terminated */
4521 break; 4518 break;
4522 FD_SET (XINT (wait_proc->infd), &Available); 4519 FD_SET (wait_proc->infd, &Available);
4523 check_delay = 0; 4520 check_delay = 0;
4524 IF_NON_BLOCKING_CONNECT (check_connect = 0); 4521 IF_NON_BLOCKING_CONNECT (check_connect = 0);
4525 } 4522 }
@@ -4567,7 +4564,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4567 4564
4568#ifdef ADAPTIVE_READ_BUFFERING 4565#ifdef ADAPTIVE_READ_BUFFERING
4569 /* Set the timeout for adaptive read buffering if any 4566 /* Set the timeout for adaptive read buffering if any
4570 process has non-nil read_output_skip and non-zero 4567 process has non-zero read_output_skip and non-zero
4571 read_output_delay, and we are not reading output for a 4568 read_output_delay, and we are not reading output for a
4572 specific wait_channel. It is not executed if 4569 specific wait_channel. It is not executed if
4573 Vprocess_adaptive_read_buffering is nil. */ 4570 Vprocess_adaptive_read_buffering is nil. */
@@ -4582,16 +4579,16 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4582 if (NILP (proc)) 4579 if (NILP (proc))
4583 continue; 4580 continue;
4584 /* Find minimum non-zero read_output_delay among the 4581 /* Find minimum non-zero read_output_delay among the
4585 processes with non-nil read_output_skip. */ 4582 processes with non-zero read_output_skip. */
4586 if (XINT (XPROCESS (proc)->read_output_delay) > 0) 4583 if (XPROCESS (proc)->read_output_delay > 0)
4587 { 4584 {
4588 check_delay--; 4585 check_delay--;
4589 if (NILP (XPROCESS (proc)->read_output_skip)) 4586 if (!XPROCESS (proc)->read_output_skip)
4590 continue; 4587 continue;
4591 FD_CLR (channel, &Available); 4588 FD_CLR (channel, &Available);
4592 XPROCESS (proc)->read_output_skip = Qnil; 4589 XPROCESS (proc)->read_output_skip = 0;
4593 if (XINT (XPROCESS (proc)->read_output_delay) < usecs) 4590 if (XPROCESS (proc)->read_output_delay < usecs)
4594 usecs = XINT (XPROCESS (proc)->read_output_delay); 4591 usecs = XPROCESS (proc)->read_output_delay;
4595 } 4592 }
4596 } 4593 }
4597 EMACS_SET_SECS_USECS (timeout, 0, usecs); 4594 EMACS_SET_SECS_USECS (timeout, 0, usecs);
@@ -4864,7 +4861,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4864 else 4861 else
4865 { 4862 {
4866 /* Preserve status of processes already terminated. */ 4863 /* Preserve status of processes already terminated. */
4867 XSETINT (XPROCESS (proc)->tick, ++process_tick); 4864 XPROCESS (proc)->tick = ++process_tick;
4868 deactivate_process (proc); 4865 deactivate_process (proc);
4869 if (XPROCESS (proc)->raw_status_new) 4866 if (XPROCESS (proc)->raw_status_new)
4870 update_status (XPROCESS (proc)); 4867 update_status (XPROCESS (proc));
@@ -4916,7 +4913,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4916#endif 4913#endif
4917 if (xerrno) 4914 if (xerrno)
4918 { 4915 {
4919 XSETINT (p->tick, ++process_tick); 4916 p->tick = ++process_tick;
4920 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)); 4917 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil));
4921 deactivate_process (proc); 4918 deactivate_process (proc);
4922 } 4919 }
@@ -4929,8 +4926,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4929 exec_sentinel (proc, build_string ("open\n")); 4926 exec_sentinel (proc, build_string ("open\n"));
4930 if (!EQ (p->filter, Qt) && !EQ (p->command, Qt)) 4927 if (!EQ (p->filter, Qt) && !EQ (p->command, Qt))
4931 { 4928 {
4932 FD_SET (XINT (p->infd), &input_wait_mask); 4929 FD_SET (p->infd, &input_wait_mask);
4933 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 4930 FD_SET (p->infd, &non_keyboard_wait_mask);
4934 } 4931 }
4935 } 4932 }
4936 } 4933 }
@@ -5004,7 +5001,7 @@ read_process_output (proc, channel)
5004 register struct Lisp_Process *p = XPROCESS (proc); 5001 register struct Lisp_Process *p = XPROCESS (proc);
5005 register int opoint; 5002 register int opoint;
5006 struct coding_system *coding = proc_decode_coding_system[channel]; 5003 struct coding_system *coding = proc_decode_coding_system[channel];
5007 int carryover = XINT (p->decoding_carryover); 5004 int carryover = p->decoding_carryover;
5008 int readmax = 4096; 5005 int readmax = 4096;
5009 5006
5010#ifdef VMS 5007#ifdef VMS
@@ -5057,9 +5054,9 @@ read_process_output (proc, channel)
5057 { 5054 {
5058 nbytes = emacs_read (channel, chars + carryover, readmax); 5055 nbytes = emacs_read (channel, chars + carryover, readmax);
5059#ifdef ADAPTIVE_READ_BUFFERING 5056#ifdef ADAPTIVE_READ_BUFFERING
5060 if (nbytes > 0 && !NILP (p->adaptive_read_buffering)) 5057 if (nbytes > 0 && p->adaptive_read_buffering)
5061 { 5058 {
5062 int delay = XINT (p->read_output_delay); 5059 int delay = p->read_output_delay;
5063 if (nbytes < 256) 5060 if (nbytes < 256)
5064 { 5061 {
5065 if (delay < READ_OUTPUT_DELAY_MAX_MAX) 5062 if (delay < READ_OUTPUT_DELAY_MAX_MAX)
@@ -5075,10 +5072,10 @@ read_process_output (proc, channel)
5075 if (delay == 0) 5072 if (delay == 0)
5076 process_output_delay_count--; 5073 process_output_delay_count--;
5077 } 5074 }
5078 XSETINT (p->read_output_delay, delay); 5075 p->read_output_delay = delay;
5079 if (delay) 5076 if (delay)
5080 { 5077 {
5081 p->read_output_skip = Qt; 5078 p->read_output_skip = 1;
5082 process_output_skip = 1; 5079 process_output_skip = 1;
5083 } 5080 }
5084 } 5081 }
@@ -5096,7 +5093,7 @@ read_process_output (proc, channel)
5096 } 5093 }
5097#endif /* not VMS */ 5094#endif /* not VMS */
5098 5095
5099 XSETINT (p->decoding_carryover, 0); 5096 p->decoding_carryover = 0;
5100 5097
5101 /* At this point, NBYTES holds number of bytes just received 5098 /* At this point, NBYTES holds number of bytes just received
5102 (including the one in proc_buffered_char[channel]). */ 5099 (including the one in proc_buffered_char[channel]). */
@@ -5170,14 +5167,14 @@ read_process_output (proc, channel)
5170 valid memory because p->outfd will be changed once EOF is 5167 valid memory because p->outfd will be changed once EOF is
5171 sent to the process. */ 5168 sent to the process. */
5172 if (NILP (p->encode_coding_system) 5169 if (NILP (p->encode_coding_system)
5173 && proc_encode_coding_system[XINT (p->outfd)]) 5170 && proc_encode_coding_system[p->outfd])
5174 { 5171 {
5175 p->encode_coding_system = coding->symbol; 5172 p->encode_coding_system = coding->symbol;
5176 setup_coding_system (coding->symbol, 5173 setup_coding_system (coding->symbol,
5177 proc_encode_coding_system[XINT (p->outfd)]); 5174 proc_encode_coding_system[p->outfd]);
5178 if (proc_encode_coding_system[XINT (p->outfd)]->eol_type 5175 if (proc_encode_coding_system[p->outfd]->eol_type
5179 == CODING_EOL_UNDECIDED) 5176 == CODING_EOL_UNDECIDED)
5180 proc_encode_coding_system[XINT (p->outfd)]->eol_type 5177 proc_encode_coding_system[p->outfd]->eol_type
5181 = system_eol_type; 5178 = system_eol_type;
5182 } 5179 }
5183 } 5180 }
@@ -5190,9 +5187,9 @@ read_process_output (proc, channel)
5190 p->decoding_buf = make_uninit_string (carryover); 5187 p->decoding_buf = make_uninit_string (carryover);
5191 bcopy (chars + coding->consumed, SDATA (p->decoding_buf), 5188 bcopy (chars + coding->consumed, SDATA (p->decoding_buf),
5192 carryover); 5189 carryover);
5193 XSETINT (p->decoding_carryover, carryover); 5190 p->decoding_carryover = carryover;
5194 /* Adjust the multibyteness of TEXT to that of the filter. */ 5191 /* Adjust the multibyteness of TEXT to that of the filter. */
5195 if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text)) 5192 if (p->filter_multibyte != STRING_MULTIBYTE (text))
5196 text = (STRING_MULTIBYTE (text) 5193 text = (STRING_MULTIBYTE (text)
5197 ? Fstring_as_unibyte (text) 5194 ? Fstring_as_unibyte (text)
5198 : Fstring_to_multibyte (text)); 5195 : Fstring_to_multibyte (text));
@@ -5284,14 +5281,14 @@ read_process_output (proc, channel)
5284 { 5281 {
5285 p->decode_coding_system = coding->symbol; 5282 p->decode_coding_system = coding->symbol;
5286 if (NILP (p->encode_coding_system) 5283 if (NILP (p->encode_coding_system)
5287 && proc_encode_coding_system[XINT (p->outfd)]) 5284 && proc_encode_coding_system[p->outfd])
5288 { 5285 {
5289 p->encode_coding_system = coding->symbol; 5286 p->encode_coding_system = coding->symbol;
5290 setup_coding_system (coding->symbol, 5287 setup_coding_system (coding->symbol,
5291 proc_encode_coding_system[XINT (p->outfd)]); 5288 proc_encode_coding_system[p->outfd]);
5292 if (proc_encode_coding_system[XINT (p->outfd)]->eol_type 5289 if (proc_encode_coding_system[p->outfd]->eol_type
5293 == CODING_EOL_UNDECIDED) 5290 == CODING_EOL_UNDECIDED)
5294 proc_encode_coding_system[XINT (p->outfd)]->eol_type 5291 proc_encode_coding_system[p->outfd]->eol_type
5295 = system_eol_type; 5292 = system_eol_type;
5296 } 5293 }
5297 } 5294 }
@@ -5303,7 +5300,7 @@ read_process_output (proc, channel)
5303 p->decoding_buf = make_uninit_string (carryover); 5300 p->decoding_buf = make_uninit_string (carryover);
5304 bcopy (chars + coding->consumed, SDATA (p->decoding_buf), 5301 bcopy (chars + coding->consumed, SDATA (p->decoding_buf),
5305 carryover); 5302 carryover);
5306 XSETINT (p->decoding_carryover, carryover); 5303 p->decoding_carryover = carryover;
5307 5304
5308 /* Adjust the multibyteness of TEXT to that of the buffer. */ 5305 /* Adjust the multibyteness of TEXT to that of the buffer. */
5309 if (NILP (current_buffer->enable_multibyte_characters) 5306 if (NILP (current_buffer->enable_multibyte_characters)
@@ -5422,10 +5419,10 @@ send_process (proc, buf, len, object)
5422 update_status (p); 5419 update_status (p);
5423 if (! EQ (p->status, Qrun)) 5420 if (! EQ (p->status, Qrun))
5424 error ("Process %s not running", SDATA (p->name)); 5421 error ("Process %s not running", SDATA (p->name));
5425 if (XINT (p->outfd) < 0) 5422 if (p->outfd < 0)
5426 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5423 error ("Output file descriptor of %s is closed", SDATA (p->name));
5427 5424
5428 coding = proc_encode_coding_system[XINT (p->outfd)]; 5425 coding = proc_encode_coding_system[p->outfd];
5429 Vlast_coding_system_used = coding->symbol; 5426 Vlast_coding_system_used = coding->symbol;
5430 5427
5431 if ((STRINGP (object) && STRING_MULTIBYTE (object)) 5428 if ((STRINGP (object) && STRING_MULTIBYTE (object))
@@ -5518,7 +5515,7 @@ send_process (proc, buf, len, object)
5518 if (pty_max_bytes == 0) 5515 if (pty_max_bytes == 0)
5519 { 5516 {
5520#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) 5517#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
5521 pty_max_bytes = fpathconf (XFASTINT (p->outfd), _PC_MAX_CANON); 5518 pty_max_bytes = fpathconf (p->outfd, _PC_MAX_CANON);
5522 if (pty_max_bytes < 0) 5519 if (pty_max_bytes < 0)
5523 pty_max_bytes = 250; 5520 pty_max_bytes = 250;
5524#else 5521#else
@@ -5540,7 +5537,7 @@ send_process (proc, buf, len, object)
5540 5537
5541 /* Decide how much data we can send in one batch. 5538 /* Decide how much data we can send in one batch.
5542 Long lines need to be split into multiple batches. */ 5539 Long lines need to be split into multiple batches. */
5543 if (!NILP (p->pty_flag)) 5540 if (p->pty_flag)
5544 { 5541 {
5545 /* Starting this at zero is always correct when not the first 5542 /* Starting this at zero is always correct when not the first
5546 iteration because the previous iteration ended by sending C-d. 5543 iteration because the previous iteration ended by sending C-d.
@@ -5569,7 +5566,7 @@ send_process (proc, buf, len, object)
5569 /* Send this batch, using one or more write calls. */ 5566 /* Send this batch, using one or more write calls. */
5570 while (this > 0) 5567 while (this > 0)
5571 { 5568 {
5572 int outfd = XINT (p->outfd); 5569 int outfd = p->outfd;
5573 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); 5570 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap);
5574#ifdef DATAGRAM_SOCKETS 5571#ifdef DATAGRAM_SOCKETS
5575 if (DATAGRAM_CHAN_P (outfd)) 5572 if (DATAGRAM_CHAN_P (outfd))
@@ -5589,12 +5586,12 @@ send_process (proc, buf, len, object)
5589 { 5586 {
5590 rv = emacs_write (outfd, (char *) buf, this); 5587 rv = emacs_write (outfd, (char *) buf, this);
5591#ifdef ADAPTIVE_READ_BUFFERING 5588#ifdef ADAPTIVE_READ_BUFFERING
5592 if (XINT (p->read_output_delay) > 0 5589 if (p->read_output_delay > 0
5593 && EQ (p->adaptive_read_buffering, Qt)) 5590 && p->adaptive_read_buffering == 1)
5594 { 5591 {
5595 XSETFASTINT (p->read_output_delay, 0); 5592 p->read_output_delay = 0;
5596 process_output_delay_count--; 5593 process_output_delay_count--;
5597 p->read_output_skip = Qnil; 5594 p->read_output_skip = 0;
5598 } 5595 }
5599#endif 5596#endif
5600 } 5597 }
@@ -5637,7 +5634,7 @@ send_process (proc, buf, len, object)
5637 if (errno == EAGAIN) 5634 if (errno == EAGAIN)
5638 { 5635 {
5639 int flags = FWRITE; 5636 int flags = FWRITE;
5640 ioctl (XINT (p->outfd), TIOCFLUSH, &flags); 5637 ioctl (p->outfd, TIOCFLUSH, &flags);
5641 } 5638 }
5642#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ 5639#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
5643 5640
@@ -5686,7 +5683,7 @@ send_process (proc, buf, len, object)
5686#endif 5683#endif
5687 p->raw_status_new = 0; 5684 p->raw_status_new = 0;
5688 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5685 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil));
5689 XSETINT (p->tick, ++process_tick); 5686 p->tick = ++process_tick;
5690 deactivate_process (proc); 5687 deactivate_process (proc);
5691#ifdef VMS 5688#ifdef VMS
5692 error ("Error writing to process %s; closed it", SDATA (p->name)); 5689 error ("Error writing to process %s; closed it", SDATA (p->name));
@@ -5738,10 +5735,10 @@ send_process_object (proc, start, end)
5738 update_status (p); 5735 update_status (p);
5739 if (! EQ (p->status, Qrun)) 5736 if (! EQ (p->status, Qrun))
5740 error ("Process %s not running", SDATA (p->name)); 5737 error ("Process %s not running", SDATA (p->name));
5741 if (XINT (p->outfd) < 0) 5738 if (p->outfd < 0)
5742 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5739 error ("Output file descriptor of %s is closed", SDATA (p->name));
5743 5740
5744 coding = proc_encode_coding_system[XINT (p->outfd)]; 5741 coding = proc_encode_coding_system[p->outfd];
5745 if (! EQ (coding->symbol, p->encode_coding_system)) 5742 if (! EQ (coding->symbol, p->encode_coding_system))
5746 /* The coding system for encoding was changed to raw-text 5743 /* The coding system for encoding was changed to raw-text
5747 because we sent a unibyte text previously. Now we are 5744 because we sent a unibyte text previously. Now we are
@@ -5830,7 +5827,7 @@ emacs_get_tty_pgrp (p)
5830 int gid = -1; 5827 int gid = -1;
5831 5828
5832#ifdef TIOCGPGRP 5829#ifdef TIOCGPGRP
5833 if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) 5830 if (ioctl (p->infd, TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name))
5834 { 5831 {
5835 int fd; 5832 int fd;
5836 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the 5833 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the
@@ -5868,7 +5865,7 @@ return t unconditionally. */)
5868 if (!EQ (p->childp, Qt)) 5865 if (!EQ (p->childp, Qt))
5869 error ("Process %s is not a subprocess", 5866 error ("Process %s is not a subprocess",
5870 SDATA (p->name)); 5867 SDATA (p->name));
5871 if (XINT (p->infd) < 0) 5868 if (p->infd < 0)
5872 error ("Process %s is not active", 5869 error ("Process %s is not active",
5873 SDATA (p->name)); 5870 SDATA (p->name));
5874 5871
@@ -5911,11 +5908,11 @@ process_send_signal (process, signo, current_group, nomsg)
5911 if (!EQ (p->childp, Qt)) 5908 if (!EQ (p->childp, Qt))
5912 error ("Process %s is not a subprocess", 5909 error ("Process %s is not a subprocess",
5913 SDATA (p->name)); 5910 SDATA (p->name));
5914 if (XINT (p->infd) < 0) 5911 if (p->infd < 0)
5915 error ("Process %s is not active", 5912 error ("Process %s is not active",
5916 SDATA (p->name)); 5913 SDATA (p->name));
5917 5914
5918 if (NILP (p->pty_flag)) 5915 if (!p->pty_flag)
5919 current_group = Qnil; 5916 current_group = Qnil;
5920 5917
5921 /* If we are using pgrps, get a pgrp number and make it negative. */ 5918 /* If we are using pgrps, get a pgrp number and make it negative. */
@@ -5934,7 +5931,7 @@ process_send_signal (process, signo, current_group, nomsg)
5934 struct termios t; 5931 struct termios t;
5935 cc_t *sig_char = NULL; 5932 cc_t *sig_char = NULL;
5936 5933
5937 tcgetattr (XINT (p->infd), &t); 5934 tcgetattr (p->infd, &t);
5938 5935
5939 switch (signo) 5936 switch (signo)
5940 { 5937 {
@@ -5974,16 +5971,16 @@ process_send_signal (process, signo, current_group, nomsg)
5974 switch (signo) 5971 switch (signo)
5975 { 5972 {
5976 case SIGINT: 5973 case SIGINT:
5977 ioctl (XINT (p->infd), TIOCGETC, &c); 5974 ioctl (p->infd, TIOCGETC, &c);
5978 send_process (proc, &c.t_intrc, 1, Qnil); 5975 send_process (proc, &c.t_intrc, 1, Qnil);
5979 return; 5976 return;
5980 case SIGQUIT: 5977 case SIGQUIT:
5981 ioctl (XINT (p->infd), TIOCGETC, &c); 5978 ioctl (p->infd, TIOCGETC, &c);
5982 send_process (proc, &c.t_quitc, 1, Qnil); 5979 send_process (proc, &c.t_quitc, 1, Qnil);
5983 return; 5980 return;
5984#ifdef SIGTSTP 5981#ifdef SIGTSTP
5985 case SIGTSTP: 5982 case SIGTSTP:
5986 ioctl (XINT (p->infd), TIOCGLTC, &lc); 5983 ioctl (p->infd, TIOCGLTC, &lc);
5987 send_process (proc, &lc.t_suspc, 1, Qnil); 5984 send_process (proc, &lc.t_suspc, 1, Qnil);
5988 return; 5985 return;
5989#endif /* ! defined (SIGTSTP) */ 5986#endif /* ! defined (SIGTSTP) */
@@ -5998,16 +5995,16 @@ process_send_signal (process, signo, current_group, nomsg)
5998 switch (signo) 5995 switch (signo)
5999 { 5996 {
6000 case SIGINT: 5997 case SIGINT:
6001 ioctl (XINT (p->infd), TCGETA, &t); 5998 ioctl (p->infd, TCGETA, &t);
6002 send_process (proc, &t.c_cc[VINTR], 1, Qnil); 5999 send_process (proc, &t.c_cc[VINTR], 1, Qnil);
6003 return; 6000 return;
6004 case SIGQUIT: 6001 case SIGQUIT:
6005 ioctl (XINT (p->infd), TCGETA, &t); 6002 ioctl (p->infd, TCGETA, &t);
6006 send_process (proc, &t.c_cc[VQUIT], 1, Qnil); 6003 send_process (proc, &t.c_cc[VQUIT], 1, Qnil);
6007 return; 6004 return;
6008#ifdef SIGTSTP 6005#ifdef SIGTSTP
6009 case SIGTSTP: 6006 case SIGTSTP:
6010 ioctl (XINT (p->infd), TCGETA, &t); 6007 ioctl (p->infd, TCGETA, &t);
6011 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); 6008 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil);
6012 return; 6009 return;
6013#endif /* ! defined (SIGTSTP) */ 6010#endif /* ! defined (SIGTSTP) */
@@ -6065,7 +6062,7 @@ process_send_signal (process, signo, current_group, nomsg)
6065 case SIGCONT: 6062 case SIGCONT:
6066 p->raw_status_new = 0; 6063 p->raw_status_new = 0;
6067 p->status = Qrun; 6064 p->status = Qrun;
6068 XSETINT (p->tick, ++process_tick); 6065 p->tick = ++process_tick;
6069 if (!nomsg) 6066 if (!nomsg)
6070 status_notify (NULL); 6067 status_notify (NULL);
6071 break; 6068 break;
@@ -6085,7 +6082,7 @@ process_send_signal (process, signo, current_group, nomsg)
6085 sys$forcex (&(p->pid), 0, 1); 6082 sys$forcex (&(p->pid), 0, 1);
6086 whoosh: 6083 whoosh:
6087#endif 6084#endif
6088 flush_pending_output (XINT (p->infd)); 6085 flush_pending_output (p->infd);
6089 break; 6086 break;
6090 } 6087 }
6091 6088
@@ -6102,7 +6099,7 @@ process_send_signal (process, signo, current_group, nomsg)
6102#ifdef TIOCSIGSEND 6099#ifdef TIOCSIGSEND
6103 if (!NILP (current_group)) 6100 if (!NILP (current_group))
6104 { 6101 {
6105 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) 6102 if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
6106 EMACS_KILLPG (gid, signo); 6103 EMACS_KILLPG (gid, signo);
6107 } 6104 }
6108 else 6105 else
@@ -6168,10 +6165,10 @@ If PROCESS is a network process, inhibit handling of incoming traffic. */)
6168 6165
6169 p = XPROCESS (process); 6166 p = XPROCESS (process);
6170 if (NILP (p->command) 6167 if (NILP (p->command)
6171 && XINT (p->infd) >= 0) 6168 && p->infd >= 0)
6172 { 6169 {
6173 FD_CLR (XINT (p->infd), &input_wait_mask); 6170 FD_CLR (p->infd, &input_wait_mask);
6174 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6171 FD_CLR (p->infd, &non_keyboard_wait_mask);
6175 } 6172 }
6176 p->command = Qt; 6173 p->command = Qt;
6177 return process; 6174 return process;
@@ -6199,11 +6196,11 @@ If PROCESS is a network process, resume handling of incoming traffic. */)
6199 6196
6200 p = XPROCESS (process); 6197 p = XPROCESS (process);
6201 if (EQ (p->command, Qt) 6198 if (EQ (p->command, Qt)
6202 && XINT (p->infd) >= 0 6199 && p->infd >= 0
6203 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) 6200 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten)))
6204 { 6201 {
6205 FD_SET (XINT (p->infd), &input_wait_mask); 6202 FD_SET (p->infd, &input_wait_mask);
6206 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); 6203 FD_SET (p->infd, &non_keyboard_wait_mask);
6207 } 6204 }
6208 p->command = Qnil; 6205 p->command = Qnil;
6209 return process; 6206 return process;
@@ -6400,7 +6397,7 @@ text to PROCESS after you call this function. */)
6400 return process; 6397 return process;
6401 6398
6402 proc = get_process (process); 6399 proc = get_process (process);
6403 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 6400 coding = proc_encode_coding_system[XPROCESS (proc)->outfd];
6404 6401
6405 /* Make sure the process is really alive. */ 6402 /* Make sure the process is really alive. */
6406 if (XPROCESS (proc)->raw_status_new) 6403 if (XPROCESS (proc)->raw_status_new)
@@ -6417,7 +6414,7 @@ text to PROCESS after you call this function. */)
6417#ifdef VMS 6414#ifdef VMS
6418 send_process (proc, "\032", 1, Qnil); /* ^z */ 6415 send_process (proc, "\032", 1, Qnil); /* ^z */
6419#else 6416#else
6420 if (!NILP (XPROCESS (proc)->pty_flag)) 6417 if (XPROCESS (proc)->pty_flag)
6421 send_process (proc, "\004", 1, Qnil); 6418 send_process (proc, "\004", 1, Qnil);
6422 else 6419 else
6423 { 6420 {
@@ -6429,18 +6426,18 @@ text to PROCESS after you call this function. */)
6429 (In some old system, shutdown to socketpair doesn't work. 6426 (In some old system, shutdown to socketpair doesn't work.
6430 Then we just can't win.) */ 6427 Then we just can't win.) */
6431 if (XPROCESS (proc)->pid == 0 6428 if (XPROCESS (proc)->pid == 0
6432 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) 6429 || XPROCESS (proc)->outfd == XPROCESS (proc)->infd)
6433 shutdown (XINT (XPROCESS (proc)->outfd), 1); 6430 shutdown (XPROCESS (proc)->outfd, 1);
6434 /* In case of socketpair, outfd == infd, so don't close it. */ 6431 /* In case of socketpair, outfd == infd, so don't close it. */
6435 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) 6432 if (XPROCESS (proc)->outfd != XPROCESS (proc)->infd)
6436 emacs_close (XINT (XPROCESS (proc)->outfd)); 6433 emacs_close (XPROCESS (proc)->outfd);
6437#else /* not HAVE_SHUTDOWN */ 6434#else /* not HAVE_SHUTDOWN */
6438 emacs_close (XINT (XPROCESS (proc)->outfd)); 6435 emacs_close (XPROCESS (proc)->outfd);
6439#endif /* not HAVE_SHUTDOWN */ 6436#endif /* not HAVE_SHUTDOWN */
6440 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); 6437 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
6441 if (new_outfd < 0) 6438 if (new_outfd < 0)
6442 abort (); 6439 abort ();
6443 old_outfd = XINT (XPROCESS (proc)->outfd); 6440 old_outfd = XPROCESS (proc)->outfd;
6444 6441
6445 if (!proc_encode_coding_system[new_outfd]) 6442 if (!proc_encode_coding_system[new_outfd])
6446 proc_encode_coding_system[new_outfd] 6443 proc_encode_coding_system[new_outfd]
@@ -6451,7 +6448,7 @@ text to PROCESS after you call this function. */)
6451 bzero (proc_encode_coding_system[old_outfd], 6448 bzero (proc_encode_coding_system[old_outfd],
6452 sizeof (struct coding_system)); 6449 sizeof (struct coding_system));
6453 6450
6454 XSETINT (XPROCESS (proc)->outfd, new_outfd); 6451 XPROCESS (proc)->outfd = new_outfd;
6455 } 6452 }
6456#endif /* VMS */ 6453#endif /* VMS */
6457 return process; 6454 return process;
@@ -6474,7 +6471,7 @@ kill_buffer_processes (buffer)
6474 { 6471 {
6475 if (NETCONN_P (proc)) 6472 if (NETCONN_P (proc))
6476 Fdelete_process (proc); 6473 Fdelete_process (proc);
6477 else if (XINT (XPROCESS (proc)->infd) >= 0) 6474 else if (XPROCESS (proc)->infd >= 0)
6478 process_send_signal (proc, SIGHUP, Qnil, 1); 6475 process_send_signal (proc, SIGHUP, Qnil, 1);
6479 } 6476 }
6480 } 6477 }
@@ -6604,21 +6601,21 @@ sigchld_handler (signo)
6604 union { int i; WAITTYPE wt; } u; 6601 union { int i; WAITTYPE wt; } u;
6605 int clear_desc_flag = 0; 6602 int clear_desc_flag = 0;
6606 6603
6607 XSETINT (p->tick, ++process_tick); 6604 p->tick = ++process_tick;
6608 u.wt = w; 6605 u.wt = w;
6609 p->raw_status = u.i; 6606 p->raw_status = u.i;
6610 p->raw_status_new = 1; 6607 p->raw_status_new = 1;
6611 6608
6612 /* If process has terminated, stop waiting for its output. */ 6609 /* If process has terminated, stop waiting for its output. */
6613 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6610 if ((WIFSIGNALED (w) || WIFEXITED (w))
6614 && XINT (p->infd) >= 0) 6611 && p->infd >= 0)
6615 clear_desc_flag = 1; 6612 clear_desc_flag = 1;
6616 6613
6617 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ 6614 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */
6618 if (clear_desc_flag) 6615 if (clear_desc_flag)
6619 { 6616 {
6620 FD_CLR (XINT (p->infd), &input_wait_mask); 6617 FD_CLR (p->infd, &input_wait_mask);
6621 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6618 FD_CLR (p->infd, &non_keyboard_wait_mask);
6622 } 6619 }
6623 6620
6624 /* Tell wait_reading_process_output that it needs to wake up and 6621 /* Tell wait_reading_process_output that it needs to wake up and
@@ -6795,18 +6792,18 @@ status_notify (deleting_process)
6795 proc = Fcdr (Fcar (tail)); 6792 proc = Fcdr (Fcar (tail));
6796 p = XPROCESS (proc); 6793 p = XPROCESS (proc);
6797 6794
6798 if (XINT (p->tick) != XINT (p->update_tick)) 6795 if (p->tick != p->update_tick)
6799 { 6796 {
6800 XSETINT (p->update_tick, XINT (p->tick)); 6797 p->update_tick = p->tick;
6801 6798
6802 /* If process is still active, read any output that remains. */ 6799 /* If process is still active, read any output that remains. */
6803 while (! EQ (p->filter, Qt) 6800 while (! EQ (p->filter, Qt)
6804 && ! EQ (p->status, Qconnect) 6801 && ! EQ (p->status, Qconnect)
6805 && ! EQ (p->status, Qlisten) 6802 && ! EQ (p->status, Qlisten)
6806 && ! EQ (p->command, Qt) /* Network process not stopped. */ 6803 && ! EQ (p->command, Qt) /* Network process not stopped. */
6807 && XINT (p->infd) >= 0 6804 && p->infd >= 0
6808 && p != deleting_process 6805 && p != deleting_process
6809 && read_process_output (proc, XINT (p->infd)) > 0); 6806 && read_process_output (proc, p->infd) > 0);
6810 6807
6811 buffer = p->buffer; 6808 buffer = p->buffer;
6812 6809
@@ -6833,7 +6830,7 @@ status_notify (deleting_process)
6833 So set p->update_tick again 6830 So set p->update_tick again
6834 so that an error in the sentinel will not cause 6831 so that an error in the sentinel will not cause
6835 this code to be run again. */ 6832 this code to be run again. */
6836 XSETINT (p->update_tick, XINT (p->tick)); 6833 p->update_tick = p->tick;
6837 /* Now output the message suitably. */ 6834 /* Now output the message suitably. */
6838 if (!NILP (p->sentinel)) 6835 if (!NILP (p->sentinel))
6839 exec_sentinel (proc, msg); 6836 exec_sentinel (proc, msg);
@@ -6906,9 +6903,9 @@ encode subprocess input. */)
6906 6903
6907 CHECK_PROCESS (process); 6904 CHECK_PROCESS (process);
6908 p = XPROCESS (process); 6905 p = XPROCESS (process);
6909 if (XINT (p->infd) < 0) 6906 if (p->infd < 0)
6910 error ("Input file descriptor of %s closed", SDATA (p->name)); 6907 error ("Input file descriptor of %s closed", SDATA (p->name));
6911 if (XINT (p->outfd) < 0) 6908 if (p->outfd < 0)
6912 error ("Output file descriptor of %s closed", SDATA (p->name)); 6909 error ("Output file descriptor of %s closed", SDATA (p->name));
6913 Fcheck_coding_system (decoding); 6910 Fcheck_coding_system (decoding);
6914 Fcheck_coding_system (encoding); 6911 Fcheck_coding_system (encoding);
@@ -6945,7 +6942,7 @@ suppressed. */)
6945 6942
6946 CHECK_PROCESS (process); 6943 CHECK_PROCESS (process);
6947 p = XPROCESS (process); 6944 p = XPROCESS (process);
6948 p->filter_multibyte = flag; 6945 p->filter_multibyte = !NILP (flag);
6949 setup_process_coding_systems (process); 6946 setup_process_coding_systems (process);
6950 6947
6951 return Qnil; 6948 return Qnil;
@@ -6962,7 +6959,7 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6962 CHECK_PROCESS (process); 6959 CHECK_PROCESS (process);
6963 p = XPROCESS (process); 6960 p = XPROCESS (process);
6964 6961
6965 return (NILP (p->filter_multibyte) ? Qnil : Qt); 6962 return (p->filter_multibyte ? Qt : Qnil);
6966} 6963}
6967 6964
6968 6965
diff --git a/src/process.h b/src/process.h
index 718d2a70ea8..fd7847b5e29 100644
--- a/src/process.h
+++ b/src/process.h
@@ -36,10 +36,6 @@ struct Lisp_Process
36 { 36 {
37 EMACS_INT size; 37 EMACS_INT size;
38 struct Lisp_Vector *v_next; 38 struct Lisp_Vector *v_next;
39 /* Descriptor by which we read from this process */
40 Lisp_Object infd;
41 /* Descriptor by which we write to this process */
42 Lisp_Object outfd;
43 /* Name of subprocess terminal. */ 39 /* Name of subprocess terminal. */
44 Lisp_Object tty_name; 40 Lisp_Object tty_name;
45 /* Name of this process */ 41 /* Name of this process */
@@ -64,61 +60,65 @@ struct Lisp_Process
64 Lisp_Object plist; 60 Lisp_Object plist;
65 /* Marker set to end of last buffer-inserted output from this process */ 61 /* Marker set to end of last buffer-inserted output from this process */
66 Lisp_Object mark; 62 Lisp_Object mark;
67 /* Non-nil means kill silently if Emacs is exited.
68 This is the inverse of the `query-on-exit' flag. */
69 Lisp_Object kill_without_query;
70 /* Symbol indicating status of process. 63 /* Symbol indicating status of process.
71 This may be a symbol: run, open, or closed. 64 This may be a symbol: run, open, or closed.
72 Or it may be a list, whose car is stop, exit or signal 65 Or it may be a list, whose car is stop, exit or signal
73 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG) 66 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG)
74 or (SIGNAL_NUMBER . COREDUMP_FLAG). */ 67 or (SIGNAL_NUMBER . COREDUMP_FLAG). */
75 Lisp_Object status; 68 Lisp_Object status;
76 /* Non-nil if communicating through a pty. */
77 Lisp_Object pty_flag;
78 /* Event-count of last event in which this process changed status. */
79 Lisp_Object tick;
80 /* Event-count of last such event reported. */
81 Lisp_Object update_tick;
82 /* Coding-system for decoding the input from this process. */ 69 /* Coding-system for decoding the input from this process. */
83 Lisp_Object decode_coding_system; 70 Lisp_Object decode_coding_system;
84 /* Working buffer for decoding. */ 71 /* Working buffer for decoding. */
85 Lisp_Object decoding_buf; 72 Lisp_Object decoding_buf;
86 /* Size of carryover in decoding. */
87 Lisp_Object decoding_carryover;
88 /* Coding-system for encoding the output to this process. */ 73 /* Coding-system for encoding the output to this process. */
89 Lisp_Object encode_coding_system; 74 Lisp_Object encode_coding_system;
90 /* Working buffer for encoding. */ 75 /* Working buffer for encoding. */
91 Lisp_Object encoding_buf; 76 Lisp_Object encoding_buf;
92 /* Size of carryover in encoding. */
93 Lisp_Object encoding_carryover;
94 /* Flag to set coding-system of the process buffer from the
95 coding_system used to decode process output. */
96 Lisp_Object inherit_coding_system_flag;
97 /* Flat to decide the multibyteness of a string given to the
98 filter (if any). It is initialized to the value of
99 `default-enable-multibyte-characters' when the process is
100 generated, and can be changed by the function
101 `set-process-fileter-multibyte'. */
102 Lisp_Object filter_multibyte;
103 /* Should we delay reading output from this process.
104 Initialized from `Vprocess_adaptive_read_buffering'. */
105 Lisp_Object adaptive_read_buffering;
106 /* Hysteresis to try to read process output in larger blocks.
107 On some systems, e.g. GNU/Linux, Emacs is seen as
108 an interactive app also when reading process output, meaning
109 that process output can be read in as little as 1 byte at a
110 time. Value is micro-seconds to delay reading output from
111 this process. Range is 0 .. 50000. */
112 Lisp_Object read_output_delay;
113 /* Skip reading this process on next read. */
114 Lisp_Object read_output_skip;
115 77
116 /* After this point, there are no Lisp_Objects any more. */ 78 /* After this point, there are no Lisp_Objects any more. */
79 /* alloc.c assumes that `pid' is the first such non-Lisp slot. */
117 80
118 /* Number of this process. 81 /* Number of this process.
119 allocate_process assumes this is the first non-Lisp_Object field. 82 allocate_process assumes this is the first non-Lisp_Object field.
120 A value 0 is used for pseudo-processes such as network connections. */ 83 A value 0 is used for pseudo-processes such as network connections. */
121 pid_t pid; 84 pid_t pid;
85 /* Descriptor by which we read from this process */
86 int infd;
87 /* Descriptor by which we write to this process */
88 int outfd;
89 /* Event-count of last event in which this process changed status. */
90 int tick;
91 /* Event-count of last such event reported. */
92 int update_tick;
93 /* Size of carryover in decoding. */
94 int decoding_carryover;
95 /* Hysteresis to try to read process output in larger blocks.
96 On some systems, e.g. GNU/Linux, Emacs is seen as
97 an interactive app also when reading process output, meaning
98 that process output can be read in as little as 1 byte at a
99 time. Value is micro-seconds to delay reading output from
100 this process. Range is 0 .. 50000. */
101 int read_output_delay;
102 /* Should we delay reading output from this process.
103 Initialized from `Vprocess_adaptive_read_buffering'.
104 0 = nil, 1 = t, 2 = other. */
105 int adaptive_read_buffering : 2;
106 /* Skip reading this process on next read. */
107 int read_output_skip : 1;
108 /* Non-nil means kill silently if Emacs is exited.
109 This is the inverse of the `query-on-exit' flag. */
110 int kill_without_query : 1;
111 /* Non-nil if communicating through a pty. */
112 int pty_flag : 1;
113 /* Flag to set coding-system of the process buffer from the
114 coding_system used to decode process output. */
115 int inherit_coding_system_flag : 1;
116 /* Flag to decide the multibyteness of a string given to the
117 filter (if any). It is initialized to the value of
118 `default-enable-multibyte-characters' when the process is
119 generated, and can be changed by the function
120 `set-process-filter-multibyte'. */
121 int filter_multibyte : 1;
122 /* Record the process status in the raw form in which it comes from `wait'. 122 /* Record the process status in the raw form in which it comes from `wait'.
123 This is to avoid consing in a signal handler. The `raw_status_new' 123 This is to avoid consing in a signal handler. The `raw_status_new'
124 flag indicates that `raw_status' contains a new status that still 124 flag indicates that `raw_status' contains a new status that still