Repository navigation
IO (Unix): fixes blocking forever on incomplete terminal responses - #2653
Conversation
ffGetTerminalResponse() polls only before the first read(). If the terminal sends a response that is cut short (e.g. `\e[4;800` without the rest), the following read() in the loop blocks forever because the tty is in non-canonical mode with VMIN=1. Wait with the same timeout before every subsequent read() as well.
|
Friendly ping. This still applies cleanly on dev. Happy to change the approach if you had something else in mind for #2584. |
Isn't it a bug that should be fixed in the terminal side? Anyway, the fix should be applied on Windows too. |
Same issue as on Unix: ffGetTerminalResponse() waits for input only before the first ReadFile(). If the terminal answers only part of the request (e.g. one of the two OSC 10/11 replies), the next ReadFile() blocks forever. Wait with the same timeout before every subsequent ReadFile() as well, and restore the console mode on that error path. While waiting, also skip key-up records: ReadFile() returns no data for them, so one left alone in the buffer would end the wait and the following ReadFile() would block.
|
Fair point, a cut-off reply is the terminal's bug. Still, I don't think fastfetch should hang forever because of it: there's already a 1 s timeout before the first read, this only applies it to the following reads too. It's also not limited to broken terminals. TerminalTheme sends OSC 10 and OSC 11 in one request and expects 6 values, so a terminal that answers OSC 10 but ignores OSC 11 leaves Added the Windows side as a second commit. The wait loop before the first |
ffGetTerminalResponse()only polls before the firstread(). When the terminal answers with an incomplete response (e.g.\e[4;800for\e[14t),vsscanfmatches fewer thannParamsvalues and the loop callsread()again; withICANONoff andVMIN=1that call never returns.This waits with the same
FF_IO_TERM_RESP_WAIT_MStimeout before every subsequentread()as well. Tested on Linux with a pty that reports zero pixel size and replies to\e[14twith a full, a split (two writes, 30 ms apart) and a truncated response: before the change the truncated case hangs, after it fastfetch exits normally; full and split responses are still parsed.ctestpasses.Possibly related to #2584 (v2.67.1's
--gen-configTUI queried the terminal size on every frame; that query is skipped there since 537635c).