aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c83
1 files changed, 26 insertions, 57 deletions
diff --git a/src/process.c b/src/process.c
index 3c539024b0a..7e8f4cc57bc 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4643,6 +4643,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4643 FD_ZERO (&Connecting); 4643 FD_ZERO (&Connecting);
4644#endif 4644#endif
4645 4645
4646 if (time_limit == 0 && wait_proc && !NILP (Vinhibit_quit)
4647 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit)))
4648 message ("Blocking call to accept-process-output with quit inhibited!!");
4649
4646 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4650 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4647 if (wait_proc != NULL) 4651 if (wait_proc != NULL)
4648 wait_channel = wait_proc->infd; 4652 wait_channel = wait_proc->infd;
@@ -5314,6 +5318,8 @@ read_process_output (proc, channel)
5314 struct coding_system *coding = proc_decode_coding_system[channel]; 5318 struct coding_system *coding = proc_decode_coding_system[channel];
5315 int carryover = p->decoding_carryover; 5319 int carryover = p->decoding_carryover;
5316 int readmax = 4096; 5320 int readmax = 4096;
5321 int count = SPECPDL_INDEX ();
5322 Lisp_Object odeactivate;
5317 5323
5318 chars = (char *) alloca (carryover + readmax); 5324 chars = (char *) alloca (carryover + readmax);
5319 if (carryover) 5325 if (carryover)
@@ -5386,15 +5392,16 @@ read_process_output (proc, channel)
5386 /* Now set NBYTES how many bytes we must decode. */ 5392 /* Now set NBYTES how many bytes we must decode. */
5387 nbytes += carryover; 5393 nbytes += carryover;
5388 5394
5395 odeactivate = Vdeactivate_mark;
5396 /* There's no good reason to let process filters change the current
5397 buffer, and many callers of accept-process-output, sit-for, and
5398 friends don't expect current-buffer to be changed from under them. */
5399 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
5400
5389 /* Read and dispose of the process output. */ 5401 /* Read and dispose of the process output. */
5390 outstream = p->filter; 5402 outstream = p->filter;
5391 if (!NILP (outstream)) 5403 if (!NILP (outstream))
5392 { 5404 {
5393 /* We inhibit quit here instead of just catching it so that
5394 hitting ^G when a filter happens to be running won't screw
5395 it up. */
5396 int count = SPECPDL_INDEX ();
5397 Lisp_Object odeactivate;
5398 Lisp_Object obuffer, okeymap; 5405 Lisp_Object obuffer, okeymap;
5399 Lisp_Object text; 5406 Lisp_Object text;
5400 int outer_running_asynch_code = running_asynch_code; 5407 int outer_running_asynch_code = running_asynch_code;
@@ -5402,10 +5409,12 @@ read_process_output (proc, channel)
5402 5409
5403 /* No need to gcpro these, because all we do with them later 5410 /* No need to gcpro these, because all we do with them later
5404 is test them for EQness, and none of them should be a string. */ 5411 is test them for EQness, and none of them should be a string. */
5405 odeactivate = Vdeactivate_mark;
5406 XSETBUFFER (obuffer, current_buffer); 5412 XSETBUFFER (obuffer, current_buffer);
5407 okeymap = current_buffer->keymap; 5413 okeymap = current_buffer->keymap;
5408 5414
5415 /* We inhibit quit here instead of just catching it so that
5416 hitting ^G when a filter happens to be running won't screw
5417 it up. */
5409 specbind (Qinhibit_quit, Qt); 5418 specbind (Qinhibit_quit, Qt);
5410 specbind (Qlast_nonmenu_event, Qt); 5419 specbind (Qlast_nonmenu_event, Qt);
5411 5420
@@ -5474,9 +5483,6 @@ read_process_output (proc, channel)
5474 restore_search_regs (); 5483 restore_search_regs ();
5475 running_asynch_code = outer_running_asynch_code; 5484 running_asynch_code = outer_running_asynch_code;
5476 5485
5477 /* Handling the process output should not deactivate the mark. */
5478 Vdeactivate_mark = odeactivate;
5479
5480 /* Restore waiting_for_user_input_p as it was 5486 /* Restore waiting_for_user_input_p as it was
5481 when we were called, in case the filter clobbered it. */ 5487 when we were called, in case the filter clobbered it. */
5482 waiting_for_user_input_p = waiting; 5488 waiting_for_user_input_p = waiting;
@@ -5492,27 +5498,19 @@ read_process_output (proc, channel)
5492 cause trouble (for example it would make sit_for return). */ 5498 cause trouble (for example it would make sit_for return). */
5493 if (waiting_for_user_input_p == -1) 5499 if (waiting_for_user_input_p == -1)
5494 record_asynch_buffer_change (); 5500 record_asynch_buffer_change ();
5495
5496 unbind_to (count, Qnil);
5497 return nbytes;
5498 } 5501 }
5499 5502
5500 /* If no filter, write into buffer if it isn't dead. */ 5503 /* If no filter, write into buffer if it isn't dead. */
5501 if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) 5504 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
5502 { 5505 {
5503 Lisp_Object old_read_only; 5506 Lisp_Object old_read_only;
5504 int old_begv, old_zv; 5507 int old_begv, old_zv;
5505 int old_begv_byte, old_zv_byte; 5508 int old_begv_byte, old_zv_byte;
5506 Lisp_Object odeactivate;
5507 int before, before_byte; 5509 int before, before_byte;
5508 int opoint_byte; 5510 int opoint_byte;
5509 Lisp_Object text; 5511 Lisp_Object text;
5510 struct buffer *b; 5512 struct buffer *b;
5511 int count = SPECPDL_INDEX ();
5512
5513 odeactivate = Vdeactivate_mark;
5514 5513
5515 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
5516 Fset_buffer (p->buffer); 5514 Fset_buffer (p->buffer);
5517 opoint = PT; 5515 opoint = PT;
5518 opoint_byte = PT_BYTE; 5516 opoint_byte = PT_BYTE;
@@ -5610,13 +5608,14 @@ read_process_output (proc, channel)
5610 if (old_begv != BEGV || old_zv != ZV) 5608 if (old_begv != BEGV || old_zv != ZV)
5611 Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); 5609 Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
5612 5610
5613 /* Handling the process output should not deactivate the mark. */
5614 Vdeactivate_mark = odeactivate;
5615 5611
5616 current_buffer->read_only = old_read_only; 5612 current_buffer->read_only = old_read_only;
5617 SET_PT_BOTH (opoint, opoint_byte); 5613 SET_PT_BOTH (opoint, opoint_byte);
5618 unbind_to (count, Qnil);
5619 } 5614 }
5615 /* Handling the process output should not deactivate the mark. */
5616 Vdeactivate_mark = odeactivate;
5617
5618 unbind_to (count, Qnil);
5620 return nbytes; 5619 return nbytes;
5621} 5620}
5622 5621
@@ -5773,34 +5772,6 @@ send_process (proc, buf, len, object)
5773 { 5772 {
5774 int this = len; 5773 int this = len;
5775 5774
5776 /* Decide how much data we can send in one batch.
5777 Long lines need to be split into multiple batches. */
5778 if (p->pty_flag)
5779 {
5780 /* Starting this at zero is always correct when not the first
5781 iteration because the previous iteration ended by sending C-d.
5782 It may not be correct for the first iteration
5783 if a partial line was sent in a separate send_process call.
5784 If that proves worth handling, we need to save linepos
5785 in the process object. */
5786 int linepos = 0;
5787 unsigned char *ptr = (unsigned char *) buf;
5788 unsigned char *end = (unsigned char *) buf + len;
5789
5790 /* Scan through this text for a line that is too long. */
5791 while (ptr != end && linepos < pty_max_bytes)
5792 {
5793 if (*ptr == '\n')
5794 linepos = 0;
5795 else
5796 linepos++;
5797 ptr++;
5798 }
5799 /* If we found one, break the line there
5800 and put in a C-d to force the buffer through. */
5801 this = ptr - buf;
5802 }
5803
5804 /* Send this batch, using one or more write calls. */ 5775 /* Send this batch, using one or more write calls. */
5805 while (this > 0) 5776 while (this > 0)
5806 { 5777 {
@@ -5904,11 +5875,6 @@ send_process (proc, buf, len, object)
5904 len -= rv; 5875 len -= rv;
5905 this -= rv; 5876 this -= rv;
5906 } 5877 }
5907
5908 /* If we sent just part of the string, put in an EOF (C-d)
5909 to force it through, before we send the rest. */
5910 if (len > 0)
5911 Fprocess_send_eof (proc);
5912 } 5878 }
5913 } 5879 }
5914 else 5880 else
@@ -6845,6 +6811,11 @@ exec_sentinel (proc, reason)
6845 XSETBUFFER (obuffer, current_buffer); 6811 XSETBUFFER (obuffer, current_buffer);
6846 okeymap = current_buffer->keymap; 6812 okeymap = current_buffer->keymap;
6847 6813
6814 /* There's no good reason to let sentinels change the current
6815 buffer, and many callers of accept-process-output, sit-for, and
6816 friends don't expect current-buffer to be changed from under them. */
6817 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
6818
6848 sentinel = p->sentinel; 6819 sentinel = p->sentinel;
6849 if (NILP (sentinel)) 6820 if (NILP (sentinel))
6850 return; 6821 return;
@@ -6982,13 +6953,11 @@ status_notify (deleting_process)
6982 when a process becomes runnable. */ 6953 when a process becomes runnable. */
6983 else if (!EQ (symbol, Qrun) && !NILP (buffer)) 6954 else if (!EQ (symbol, Qrun) && !NILP (buffer))
6984 { 6955 {
6985 Lisp_Object ro, tem; 6956 Lisp_Object tem;
6986 struct buffer *old = current_buffer; 6957 struct buffer *old = current_buffer;
6987 int opoint, opoint_byte; 6958 int opoint, opoint_byte;
6988 int before, before_byte; 6959 int before, before_byte;
6989 6960
6990 ro = XBUFFER (buffer)->read_only;
6991
6992 /* Avoid error if buffer is deleted 6961 /* Avoid error if buffer is deleted
6993 (probably that's why the process is dead, too) */ 6962 (probably that's why the process is dead, too) */
6994 if (NILP (XBUFFER (buffer)->name)) 6963 if (NILP (XBUFFER (buffer)->name))