aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-27 20:22:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-27 20:22:57 -0700
commitd274b61cb59153cb705c7772527f1f43b89f2062 (patch)
tree0df2e132e31d988517c8d0d65c80474735da388c
parent824aca06ffbde70f86a72e474c051e0bf4474906 (diff)
downloadpw-d274b61cb59153cb705c7772527f1f43b89f2062.tar.gz
pw-d274b61cb59153cb705c7772527f1f43b89f2062.tar.bz2
pw-d274b61cb59153cb705c7772527f1f43b89f2062.zip
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.
-rw-r--r--pw.c1
1 files changed, 1 insertions, 0 deletions
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 ;)