Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Dec 94 14:57:11 MST
From:      terry@cs.weber.edu (Terry Lambert)
To:        mtaylor@gateway.cybernet.com (Mark J. Taylor)
Cc:        jbeukema@HK.Super.NET, freebsd-hackers@freefall.cdrom.com
Subject:   Re: how to emulate kdhit()B?
Message-ID:  <9412282157.AA05369@cs.weber.edu>
In-Reply-To: <v01510112ab276d70c7f2@[192.245.33.12]> from "Mark J. Taylor" at Dec 28, 94 02:34:31 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> At 5:24 PM 12/28/94, John Beukema wrote:
> >I cannot get the function kbhit() which works well under SCO to work under
> >FBSD.  The function which tries to read 1 char from stdin after setting
> >flags to nonblocking, always returns true ie, keyboard hit when the term
> >is in 'cooked' mode.  Can anyone point me to a way to do this?
> >jbeukema
> 
> Have you tried using fileno(stdin) in a select() call with an immediate
> return (when times=0)?  It should do the trick of emulating kbhit().

Notes:

(1)	select will return when data is available on the tty.
(2)	stdio will buffer the data from a tty into an internal buffer.
(3)	You should use 'read(2)' instead of a stdio function (like
	getc(3)) if you use select(2)!


					Terry Lambert
					terry@cs.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9412282157.AA05369>