Mercurial > emacs
comparison src/process.c @ 27705:2c53eb482802
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Workaround for FreeBSD bug. Flush output queue after EAGAIN in
write(2).
| author | Gerd Moellmann <gerd@gnu.org> |
|---|---|
| date | Tue, 15 Feb 2000 10:27:23 +0000 |
| parents | 5fddc840c29c |
| children | ef7c1ba652b2 |
comparison
equal
deleted
inserted
replaced
| 27704:e809aae28ae6 | 27705:2c53eb482802 |
|---|---|
| 3429 to finish doing output and read more. */ | 3429 to finish doing output and read more. */ |
| 3430 { | 3430 { |
| 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)) |
| 3437 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf); | 3463 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf); |
| 3438 else if (STRINGP (object)) | 3464 else if (STRINGP (object)) |
