Overview
| Artifact ID: | 6848c98d13aab5cb1e77a56b7b379210366ce7f264ded0ccd92d9302bc81488a |
|---|---|
| Ticket: | bda99f23936f7170e8f51e7e3eb52db794a3195c
gets stdin problem when non-blocking - Windows |
| User & Date: | apnadkarni on 2024-02-20 06:19:40 |
Changes
- icomment:
There were two issues. Recording for posterity. First, PeekConsoleInput was being used to check if there is input. It turns out this Win32 API only checks the console input records that have not yet been converted to text. So for example in the bug report, if the entered line was 110 characters, the ReadConsole with a buffer size of 200 (100 characters) would return 100 characters and store the remaining 10 internally for the next read. The console's input record queue would be empty so when the Tcl console driver called PeekConsoleInput, it would report no input pending. Entering another character would create a input record, thereby having the Peek indicate input and triggering a read. To fix this, the Tcl console read thread will now immediately trigger another read if the previous read completely filled the passed buffer. Tested with manually reducing read buffer size down to 20 bytes (since the fix below requires increasing buffer size for a different reason). The second issue, not reported above but mentioned on the chat is the limit of 254 characters on input lines. It seems ReadConsole will limit line lengths to the max of 256 (including crlf) and the supplied buffer size (easily checked via a simple console program). There does not seem any way around this so now the buffer size has been bumped back to 8192 as in 8.6. Note this is a single allocation *per process* in 9.0 as opposed to *per thread* in 8.6, so impact should be minimal.
- login: "apnadkarni"
- mimetype: "text/x-markdown"