Path: utzoo!utgpu!attcan!uunet!husc6!uwvax!oddjob!ncar!ames!oliveb!sun!thetone!swilson From: swilson%thetone@Sun.COM (Scott Wilson) Newsgroups: comp.unix.questions Subject: Re: how to poll keyboard Message-ID: <62727@sun.uucp> Date: 4 Aug 88 01:12:45 GMT References: <5065@husc6.harvard.edu> Sender: news@sun.uucp Reply-To: swilson@sun.UUCP (Scott Wilson) Organization: Sun Microsystems, Mountain View Lines: 19 In article <5065@husc6.harvard.edu> nakada@husc8.UUCP (Paul Nakada) writes: >I am in need of a way to read a terminal keyboard without >stopping if there is no keypress... this is the scenario.. 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. That is not a NULL pointer for the timeout struct but a struct with the time fields set to zero. This is effectively a poll of the process' controlling terminal to see if any characters have been typed. I have found some select man pages to be less than obvious about its features. 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. -- Scott Wilson arpa: swilson@sun.com "Why do dogs lick Sun Microsystems uucp: ...!sun!swilson their balls? Because Mt. View, CA they can!"