comparison src/process.c @ 107846:e8ea73860300

Try to solve the problem of spurious EOF chars in long lines of text sent to interactive subprocesses. * sysdep.c (child_setup_tty): Do not enable ICANON any more. (system_process_attributes): Remove unused var `ttotal'. * process.c (send_process): Don't bother breaking long line with EOF chars when talking to ttys any more. (wait_reading_process_output): Output a warning when called in such a way that it could block without being interruptible.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 12 Apr 2010 22:07:48 -0400
parents 992ffbd77e15
children 745e12b5af4a
comparison
equal deleted inserted replaced
107845:688679bd79f5 107846:e8ea73860300
4641 FD_ZERO (&Available); 4641 FD_ZERO (&Available);
4642 #ifdef NON_BLOCKING_CONNECT 4642 #ifdef NON_BLOCKING_CONNECT
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;
4649 4653
4650 record_unwind_protect (wait_reading_process_output_unwind, 4654 record_unwind_protect (wait_reading_process_output_unwind,
5766 process_sent_to = proc; 5770 process_sent_to = proc;
5767 while (len > 0) 5771 while (len > 0)
5768 { 5772 {
5769 int this = len; 5773 int this = len;
5770 5774
5771 /* Decide how much data we can send in one batch.
5772 Long lines need to be split into multiple batches. */
5773 if (p->pty_flag)
5774 {
5775 /* Starting this at zero is always correct when not the first
5776 iteration because the previous iteration ended by sending C-d.
5777 It may not be correct for the first iteration
5778 if a partial line was sent in a separate send_process call.
5779 If that proves worth handling, we need to save linepos
5780 in the process object. */
5781 int linepos = 0;
5782 unsigned char *ptr = (unsigned char *) buf;
5783 unsigned char *end = (unsigned char *) buf + len;
5784
5785 /* Scan through this text for a line that is too long. */
5786 while (ptr != end && linepos < pty_max_bytes)
5787 {
5788 if (*ptr == '\n')
5789 linepos = 0;
5790 else
5791 linepos++;
5792 ptr++;
5793 }
5794 /* If we found one, break the line there
5795 and put in a C-d to force the buffer through. */
5796 this = ptr - buf;
5797 }
5798
5799 /* Send this batch, using one or more write calls. */ 5775 /* Send this batch, using one or more write calls. */
5800 while (this > 0) 5776 while (this > 0)
5801 { 5777 {
5802 int outfd = p->outfd; 5778 int outfd = p->outfd;
5803 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); 5779 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap);
5897 } 5873 }
5898 buf += rv; 5874 buf += rv;
5899 len -= rv; 5875 len -= rv;
5900 this -= rv; 5876 this -= rv;
5901 } 5877 }
5902
5903 /* If we sent just part of the string, put in an EOF (C-d)
5904 to force it through, before we send the rest. */
5905 if (len > 0)
5906 Fprocess_send_eof (proc);
5907 } 5878 }
5908 } 5879 }
5909 else 5880 else
5910 { 5881 {
5911 signal (SIGPIPE, old_sigpipe); 5882 signal (SIGPIPE, old_sigpipe);