aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/src/process.c b/src/process.c
index 1abfbd3f2a4..a9a8eb79ede 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1344,11 +1344,7 @@ list_processes_1 (Lisp_Object query_only)
1344 symbol = XCAR (p->status); 1344 symbol = XCAR (p->status);
1345 1345
1346 if (EQ (symbol, Qsignal)) 1346 if (EQ (symbol, Qsignal))
1347 { 1347 Fprinc (symbol, Qnil);
1348 Lisp_Object tem;
1349 tem = Fcar (Fcdr (p->status));
1350 Fprinc (symbol, Qnil);
1351 }
1352 else if (NETCONN1_P (p) || SERIALCONN1_P (p)) 1348 else if (NETCONN1_P (p) || SERIALCONN1_P (p))
1353 { 1349 {
1354 if (EQ (symbol, Qexit)) 1350 if (EQ (symbol, Qexit))
@@ -2150,10 +2146,7 @@ void
2150create_pty (Lisp_Object process) 2146create_pty (Lisp_Object process)
2151{ 2147{
2152 int inchannel, outchannel; 2148 int inchannel, outchannel;
2153 2149 int pty_flag = 0;
2154 /* Use volatile to protect variables from being clobbered by longjmp. */
2155 volatile int forkin, forkout;
2156 volatile int pty_flag = 0;
2157 2150
2158 inchannel = outchannel = -1; 2151 inchannel = outchannel = -1;
2159 2152
@@ -2169,11 +2162,11 @@ create_pty (Lisp_Object process)
2169#ifdef O_NOCTTY 2162#ifdef O_NOCTTY
2170 /* Don't let this terminal become our controlling terminal 2163 /* Don't let this terminal become our controlling terminal
2171 (in case we don't have one). */ 2164 (in case we don't have one). */
2172 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); 2165 int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
2173#else 2166#else
2174 forkout = forkin = emacs_open (pty_name, O_RDWR, 0); 2167 int forkout = emacs_open (pty_name, O_RDWR, 0);
2175#endif 2168#endif
2176 if (forkin < 0) 2169 if (forkout < 0)
2177 report_file_error ("Opening pty", Qnil); 2170 report_file_error ("Opening pty", Qnil);
2178#if defined (DONT_REOPEN_PTY) 2171#if defined (DONT_REOPEN_PTY)
2179 /* In the case that vfork is defined as fork, the parent process 2172 /* In the case that vfork is defined as fork, the parent process
@@ -2181,8 +2174,6 @@ create_pty (Lisp_Object process)
2181 tty options setup. So we setup tty before forking. */ 2174 tty options setup. So we setup tty before forking. */
2182 child_setup_tty (forkout); 2175 child_setup_tty (forkout);
2183#endif /* DONT_REOPEN_PTY */ 2176#endif /* DONT_REOPEN_PTY */
2184#else
2185 forkin = forkout = -1;
2186#endif /* not USG, or USG_SUBTTY_WORKS */ 2177#endif /* not USG, or USG_SUBTTY_WORKS */
2187 pty_flag = 1; 2178 pty_flag = 1;
2188 } 2179 }
@@ -3958,7 +3949,7 @@ FLAGS is the current flags of the interface. */)
3958 const struct ifflag_def *fp; 3949 const struct ifflag_def *fp;
3959 int fnum; 3950 int fnum;
3960 3951
3961 any++; 3952 any = 1;
3962 for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++) 3953 for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++)
3963 { 3954 {
3964 if (flags & fp->flag_bit) 3955 if (flags & fp->flag_bit)
@@ -3986,7 +3977,7 @@ FLAGS is the current flags of the interface. */)
3986 register struct Lisp_Vector *p = XVECTOR (hwaddr); 3977 register struct Lisp_Vector *p = XVECTOR (hwaddr);
3987 int n; 3978 int n;
3988 3979
3989 any++; 3980 any = 1;
3990 for (n = 0; n < 6; n++) 3981 for (n = 0; n < 6; n++)
3991 p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]); 3982 p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]);
3992 elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr); 3983 elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr);
@@ -3998,7 +3989,7 @@ FLAGS is the current flags of the interface. */)
3998#if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined(HAVE_STRUCT_IFREQ_IFR_ADDR)) 3989#if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined(HAVE_STRUCT_IFREQ_IFR_ADDR))
3999 if (ioctl (s, SIOCGIFNETMASK, &rq) == 0) 3990 if (ioctl (s, SIOCGIFNETMASK, &rq) == 0)
4000 { 3991 {
4001 any++; 3992 any = 1;
4002#ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK 3993#ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK
4003 elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask)); 3994 elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask));
4004#else 3995#else
@@ -4012,7 +4003,7 @@ FLAGS is the current flags of the interface. */)
4012#if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR) 4003#if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR)
4013 if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) 4004 if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0)
4014 { 4005 {
4015 any++; 4006 any = 1;
4016 elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr)); 4007 elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr));
4017 } 4008 }
4018#endif 4009#endif
@@ -4022,7 +4013,7 @@ FLAGS is the current flags of the interface. */)
4022#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR) 4013#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR)
4023 if (ioctl (s, SIOCGIFADDR, &rq) == 0) 4014 if (ioctl (s, SIOCGIFADDR, &rq) == 0)
4024 { 4015 {
4025 any++; 4016 any = 1;
4026 elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); 4017 elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr));
4027 } 4018 }
4028#endif 4019#endif
@@ -5171,15 +5162,22 @@ read_process_output (Lisp_Object proc, register int channel)
5171 } 5162 }
5172 else 5163 else
5173#endif 5164#endif
5174 if (proc_buffered_char[channel] < 0)
5175 { 5165 {
5166 int buffered = 0 <= proc_buffered_char[channel];
5167 if (buffered)
5168 {
5169 chars[carryover] = proc_buffered_char[channel];
5170 proc_buffered_char[channel] = -1;
5171 }
5176#ifdef HAVE_GNUTLS 5172#ifdef HAVE_GNUTLS
5177 if (XPROCESS (proc)->gnutls_p) 5173 if (XPROCESS (proc)->gnutls_p)
5178 nbytes = emacs_gnutls_read (channel, XPROCESS (proc), 5174 nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
5179 chars + carryover, readmax); 5175 chars + carryover + buffered,
5176 readmax - buffered);
5180 else 5177 else
5181#endif 5178#endif
5182 nbytes = emacs_read (channel, chars + carryover, readmax); 5179 nbytes = emacs_read (channel, chars + carryover + buffered,
5180 readmax - buffered);
5183#ifdef ADAPTIVE_READ_BUFFERING 5181#ifdef ADAPTIVE_READ_BUFFERING
5184 if (nbytes > 0 && p->adaptive_read_buffering) 5182 if (nbytes > 0 && p->adaptive_read_buffering)
5185 { 5183 {
@@ -5193,7 +5191,7 @@ read_process_output (Lisp_Object proc, register int channel)
5193 delay += READ_OUTPUT_DELAY_INCREMENT * 2; 5191 delay += READ_OUTPUT_DELAY_INCREMENT * 2;
5194 } 5192 }
5195 } 5193 }
5196 else if (delay > 0 && (nbytes == readmax)) 5194 else if (delay > 0 && nbytes == readmax - buffered)
5197 { 5195 {
5198 delay -= READ_OUTPUT_DELAY_INCREMENT; 5196 delay -= READ_OUTPUT_DELAY_INCREMENT;
5199 if (delay == 0) 5197 if (delay == 0)
@@ -5207,22 +5205,8 @@ read_process_output (Lisp_Object proc, register int channel)
5207 } 5205 }
5208 } 5206 }
5209#endif 5207#endif
5210 } 5208 nbytes += buffered;
5211 else 5209 nbytes += buffered && nbytes <= 0;
5212 {
5213 chars[carryover] = proc_buffered_char[channel];
5214 proc_buffered_char[channel] = -1;
5215#ifdef HAVE_GNUTLS
5216 if (XPROCESS (proc)->gnutls_p)
5217 nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
5218 chars + carryover + 1, readmax - 1);
5219 else
5220#endif
5221 nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
5222 if (nbytes < 0)
5223 nbytes = 1;
5224 else
5225 nbytes = nbytes + 1;
5226 } 5210 }
5227 5211
5228 p->decoding_carryover = 0; 5212 p->decoding_carryover = 0;
@@ -5249,15 +5233,17 @@ read_process_output (Lisp_Object proc, register int channel)
5249 outstream = p->filter; 5233 outstream = p->filter;
5250 if (!NILP (outstream)) 5234 if (!NILP (outstream))
5251 { 5235 {
5252 Lisp_Object obuffer, okeymap;
5253 Lisp_Object text; 5236 Lisp_Object text;
5254 int outer_running_asynch_code = running_asynch_code; 5237 int outer_running_asynch_code = running_asynch_code;
5255 int waiting = waiting_for_user_input_p; 5238 int waiting = waiting_for_user_input_p;
5256 5239
5257 /* No need to gcpro these, because all we do with them later 5240 /* No need to gcpro these, because all we do with them later
5258 is test them for EQness, and none of them should be a string. */ 5241 is test them for EQness, and none of them should be a string. */
5242#if 0
5243 Lisp_Object obuffer, okeymap;
5259 XSETBUFFER (obuffer, current_buffer); 5244 XSETBUFFER (obuffer, current_buffer);
5260 okeymap = BVAR (current_buffer, keymap); 5245 okeymap = BVAR (current_buffer, keymap);
5246#endif
5261 5247
5262 /* We inhibit quit here instead of just catching it so that 5248 /* We inhibit quit here instead of just catching it so that
5263 hitting ^G when a filter happens to be running won't screw 5249 hitting ^G when a filter happens to be running won't screw
@@ -6540,7 +6526,7 @@ exec_sentinel_error_handler (Lisp_Object error_val)
6540static void 6526static void
6541exec_sentinel (Lisp_Object proc, Lisp_Object reason) 6527exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6542{ 6528{
6543 Lisp_Object sentinel, obuffer, odeactivate, okeymap; 6529 Lisp_Object sentinel, odeactivate;
6544 register struct Lisp_Process *p = XPROCESS (proc); 6530 register struct Lisp_Process *p = XPROCESS (proc);
6545 int count = SPECPDL_INDEX (); 6531 int count = SPECPDL_INDEX ();
6546 int outer_running_asynch_code = running_asynch_code; 6532 int outer_running_asynch_code = running_asynch_code;
@@ -6552,8 +6538,11 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6552 /* No need to gcpro these, because all we do with them later 6538 /* No need to gcpro these, because all we do with them later
6553 is test them for EQness, and none of them should be a string. */ 6539 is test them for EQness, and none of them should be a string. */
6554 odeactivate = Vdeactivate_mark; 6540 odeactivate = Vdeactivate_mark;
6541#if 0
6542 Lisp_Object obuffer, okeymap;
6555 XSETBUFFER (obuffer, current_buffer); 6543 XSETBUFFER (obuffer, current_buffer);
6556 okeymap = BVAR (current_buffer, keymap); 6544 okeymap = BVAR (current_buffer, keymap);
6545#endif
6557 6546
6558 /* There's no good reason to let sentinels change the current 6547 /* There's no good reason to let sentinels change the current
6559 buffer, and many callers of accept-process-output, sit-for, and 6548 buffer, and many callers of accept-process-output, sit-for, and