From d274b61cb59153cb705c7772527f1f43b89f2062 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 27 Apr 2022 20:22:57 -0700 Subject: Workaround: fix for issue reported by a user. We are wrongly combining poll operations with buffered reading from stdin. This means we call poll to wait for input while ignoring data already buffered in the stdio stream. When this happens at the end of a pipe, we ignore the last bit forever. The workaround is to switch stdin to unbuffered; but this means that it issues one byte read operations (inefficient) and risks blocking on partial lines. Reported by konsolebox at gmail com. --- pw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pw.c b/pw.c index 60c94b0..d7619aa 100644 --- a/pw.c +++ b/pw.c @@ -383,6 +383,7 @@ int main(int argc, char **argv) panic("unable to set TTY parameters"); setvbuf(tty, NULL, _IONBF, 0); + setvbuf(stdin, NULL, _IONBF, 0); for (unsigned stat = stat_dirty, hpos = 0, kbd_state = kbd_cmd, lasttime = ~0U; kbd_state != kbd_exit ;) -- cgit v1.2.3