diff options
| author | Gerd Moellmann | 2000-02-15 10:27:23 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-02-15 10:27:23 +0000 |
| commit | 3433b6bdab2a6a42228d3515b57e41b16e4c3cb3 (patch) | |
| tree | 260fc79ab925bd350636daed197916464af6c708 /src/process.c | |
| parent | 27a6c729329e8c934d49f5ec5a9c980807a32eef (diff) | |
| download | emacs-3433b6bdab2a6a42228d3515b57e41b16e4c3cb3.tar.gz emacs-3433b6bdab2a6a42228d3515b57e41b16e4c3cb3.zip | |
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Workaround for FreeBSD bug. Flush output queue after EAGAIN in
write(2).
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/process.c b/src/process.c index dab701a9e7f..aa83422f8c1 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3431,6 +3431,32 @@ send_process (proc, buf, len, object) | |||
| 3431 | Lisp_Object zero; | 3431 | Lisp_Object zero; |
| 3432 | int offset; | 3432 | int offset; |
| 3433 | 3433 | ||
| 3434 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN | ||
| 3435 | /* A gross hack to work around a bug in FreeBSD. | ||
| 3436 | In the following sequence, read(2) returns | ||
| 3437 | bogus data: | ||
| 3438 | |||
| 3439 | write(2) 1022 bytes | ||
| 3440 | write(2) 954 bytes, get EAGAIN | ||
| 3441 | read(2) 1024 bytes in process_read_output | ||
| 3442 | read(2) 11 bytes in process_read_output | ||
| 3443 | |||
| 3444 | That is, read(2) returns more bytes than have | ||
| 3445 | ever been written successfully. The 1033 bytes | ||
| 3446 | read are the 1022 bytes written successfully | ||
| 3447 | after processing (for example with CRs added if | ||
| 3448 | the terminal is set up that way which it is | ||
| 3449 | here). The same bytes will be seen again in a | ||
| 3450 | later read(2), without the CRs. */ | ||
| 3451 | |||
| 3452 | if (errno == EAGAIN) | ||
| 3453 | { | ||
| 3454 | int flags = FWRITE; | ||
| 3455 | ioctl (XINT (XPROCESS (proc)->outfd), TIOCFLUSH, | ||
| 3456 | &flags); | ||
| 3457 | } | ||
| 3458 | #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ | ||
| 3459 | |||
| 3434 | /* Running filters might relocate buffers or strings. | 3460 | /* Running filters might relocate buffers or strings. |
| 3435 | Arrange to relocate BUF. */ | 3461 | Arrange to relocate BUF. */ |
| 3436 | if (BUFFERP (object)) | 3462 | if (BUFFERP (object)) |