termio under SysV (kbdhit() and getch())
Guy Harris
guy at auspex.UUCP
Thu Mar 2 05:22:05 AEST 1989
>Question 1: Does 0 or -1 work as a "special" infinite value here?
(The time limit is TIME, not MIN.) Yes, 0 does indicate that no timeout
should occur.
>Question 2: Can anyone think of a better (more direct way) of finding out
> if anything is in the typeahead under SysV unix?
Without reading the character in question? No, not in general. If
you're willing to put up with having to read the character (and possibly
stuffing it into some "pushback" buffer for "getch" or something like
that), you can either 1) put the file descriptor into no-delay mode with
"fcntl" or 2) set both MIN *and* TIME to 0; either of these causes a
"read" to return what characters are there, or if there's nothing there
return 0 rather than blocking.
More information about the Comp.unix.questions
mailing list