Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Dec 1994 14:59:23 -0600 (CST)
From:      Peter da Silva <peter@bonkers.taronga.com>
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:  <199412282059.OAA04629@bonkers.taronga.com>
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?

Switch out of cooked mode.

Seriously. A routine like kbhit() is only going to work usefully in raw
or rare mode.

> 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().

I can't find an implementation of kbhit() to look at, but that's more or less
what I'd expect it'd do. But a complete implementation should ioctl() into
cbreak mode first.



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