Path: utzoo!utgpu!attcan!uunet!husc6!cmcl2!nrl-cmf!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: how to poll keyboard Message-ID: <62730@sun.uucp> Date: 4 Aug 88 01:20:05 GMT References: <5065@husc6.harvard.edu> <62727@sun.uucp> Sender: news@sun.uucp Lines: 17 > If you are using a UNIX that has the select(2) system call try > opening /dev/tty then calling select with a timeout of zero. No need to open "/dev/tty", just use the same descriptor you would use for the "read". > If your UNIX is sys5 based and has streams you can probably do > the same thing with poll(2) but I have never used it. Only if your tty driver is streams-based; the only generally-available system I know of that has no *non*-streams-based ttys is SunOS - S5R3 as distributed by AT&T still has non-streams-based ttys. However, both 4.[23]BSD and S5 support non-blocking mode on ttys; in this mode, a "read" doesn't block when no data is available, it returns -1 and sets "errno" to EWOULDBLOCK in 4.[23]BSD and returns 0 in S5. See FCNTL(2) in the BSD documentation, or FCNTL(2) and READ(2) in the S5 documentation.