*BSD News Article 70567


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!disco.iinet.net.au!news.uoregon.edu!arclight.uoregon.edu!chi-news.cic.net!usc!howland.reston.ans.net!Germany.EU.net!Dortmund.Germany.EU.net!interface-business.de!usenet
From: j@ida.interface-business.de (J Wunsch)
Newsgroups: comp.unix.bsd.bsdi.misc
Subject: Re: Q: Terminal I/O
Date: 10 Jun 1996 12:50:21 GMT
Organization: interface business GmbH, Dresden
Lines: 18
Message-ID: <4ph5me$a6k@innocence.interface-business.de>
References: <4p7b5t$f9u@hammer.msfc.nasa.gov>
Reply-To: joerg_wunsch@interface-business.de (Joerg Wunsch)
NNTP-Posting-Host: ida.interface-business.de
X-Phone: +49-351-31809-14
X-Fax: +49-351-3361187
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E

joe.gaines@msfc.nasa.gov (Joe Gaines) wrote:

> I wanted to know if there was a function in the C-Programmer that lets
> you poll the keyboard.  In Microsoft C there is a function call kbhit()
> that lets you check the keyboard for an input.  Then you can use
> getchar() to retrieve the character.  If not is there a way to do this
> without using this particular function.  Your help is appreciated.

The usual way to do this under Unix is to select() on the file
descriptor(s) you wanna watch.  Of course, you have to turn your tty
into ``raw'' mode before.

RTFM select(2), termios(7).

-- 
J"org Wunsch					       Unix support engineer
joerg_wunsch@interface-business.de       http://www.interface-business.de/~j