Disable stdin buffering in libss dummy readline
authorGreg Hudson <ghudson@mit.edu>
Wed, 3 Oct 2018 22:45:56 +0000 (18:45 -0400)
committerGreg Hudson <ghudson@mit.edu>
Thu, 4 Oct 2018 15:59:42 +0000 (11:59 -0400)
readline() is careful not to read more bytes from fd 0 than it has to.
Do the same in the dummy libss readline() by disabling stdin
buffering.

ticket: 8745

src/util/ss/listen.c

index c99caa34bd72284f322d0a008202ffd4c1ff34a0..879ebcfbd5fb4ccd7086555163694fc93ee5ca23 100644 (file)
@@ -33,6 +33,9 @@ static char *readline(const char *prompt)
     struct termios termbuf;
     char input[BUFSIZ];
 
+    /* Make sure we don't buffer anything beyond the line read. */
+    setvbuf(stdin, 0, _IONBF, 0);
+
     if (tcgetattr(STDIN_FILENO, &termbuf) == 0) {
         termbuf.c_lflag |= ICANON|ISIG|ECHO;
         tcsetattr(STDIN_FILENO, TCSANOW, &termbuf);