Newsgroups: comp.unix.shell
>extraneous characters are generated -- and they end up in the keyboard's >input buffer, so that the next prompt the user sees has these characters >present (though ...
I'll stick to some generic advice on the subject:
Some systems have a stty command which supports a "flushi" and/or a "flush" option, in which case you can use that.
Otherwise you probably will need to resort to compiling this "flushi" program:
#include <unistd.h> #include <termios.h> int main(void) { tcflush(STDIN_FILENO, TCIFLUSH); return 0; }
Some other, more kludgy solutions:
if job control (SIGTTIN) doesn't get in the way:
s=`stty -g`; stty -echo raw cat >/dev/null & sleep 3; kill $? stty $s
(where the "3" is some arbritrary delay, long enough to be confident that all pending input has been read (with a high degree of probability), short enough to not be overly annoying)
Ken Pizzini