Xref: utzoo comp.sys.att:5706 comp.unix.questions:11958 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.sys.att,comp.unix.questions Subject: Re: termio under SysV (kbdhit() and getch()) Keywords: typeahead peek, timeout on reads Message-ID: <1100@auspex.UUCP> Date: 1 Mar 89 19:22:05 GMT References: <1174@naucse.UUCP> Reply-To: guy@auspex.UUCP (Guy Harris) Distribution: usa Organization: Auspex Systems, Santa Clara Lines: 15 >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.