]> git.eshelyaron.com Git - emacs.git/commitdiff
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
authorGerd Moellmann <gerd@gnu.org>
Tue, 15 Feb 2000 10:27:23 +0000 (10:27 +0000)
committerGerd Moellmann <gerd@gnu.org>
Tue, 15 Feb 2000 10:27:23 +0000 (10:27 +0000)
Workaround for FreeBSD bug.  Flush output queue after EAGAIN in
write(2).

src/process.c

index dab701a9e7f41c6af495253ffe5a7a5f7785db43..aa83422f8c12989a45768374b15b1f9c2131ed83 100644 (file)
@@ -3431,6 +3431,32 @@ send_process (proc, buf, len, object)
                    Lisp_Object zero;
                    int offset;
 
+#ifdef BROKEN_PTY_READ_AFTER_EAGAIN
+                   /* A gross hack to work around a bug in FreeBSD.
+                      In the following sequence, read(2) returns
+                      bogus data:
+
+                      write(2)  1022 bytes
+                      write(2)   954 bytes, get EAGAIN
+                      read(2)   1024 bytes in process_read_output
+                      read(2)     11 bytes in process_read_output
+
+                      That is, read(2) returns more bytes than have
+                      ever been written successfully.  The 1033 bytes
+                      read are the 1022 bytes written successfully
+                      after processing (for example with CRs added if
+                      the terminal is set up that way which it is
+                      here).  The same bytes will be seen again in a
+                      later read(2), without the CRs.  */
+                   
+                   if (errno == EAGAIN)
+                     {
+                       int flags = FWRITE;
+                       ioctl (XINT (XPROCESS (proc)->outfd), TIOCFLUSH,
+                              &flags);
+                     }
+#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
+                   
                    /* Running filters might relocate buffers or strings.
                       Arrange to relocate BUF.  */
                    if (BUFFERP (object))