From owner-freebsd-hackers Wed Dec 28 13:28:07 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id NAA05489 for hackers-outgoing; Wed, 28 Dec 1994 13:28:07 -0800 Received: from UUCP-GW.CC.UH.EDU (root@UUCP-GW.CC.UH.EDU [129.7.1.11]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id NAA05479 for ; Wed, 28 Dec 1994 13:28:01 -0800 Received: from Taronga.COM by UUCP-GW.CC.UH.EDU with UUCP id AA24329 (5.67a/IDA-1.5); Wed, 28 Dec 1994 15:22:38 -0600 Received: by bonkers.taronga.com (smail2.5p) id AA04632; 28 Dec 94 14:59:24 CST (Wed) Received: (from peter@localhost) by bonkers.taronga.com (8.6.8/8.6.6) id OAA04629; Wed, 28 Dec 1994 14:59:23 -0600 From: Peter da Silva Message-Id: <199412282059.OAA04629@bonkers.taronga.com> Subject: Re: how to emulate kdhit()B? To: mtaylor@gateway.cybernet.com (Mark J. Taylor) Date: Wed, 28 Dec 1994 14:59:23 -0600 (CST) Cc: jbeukema@HK.Super.NET, freebsd-hackers@freefall.cdrom.com In-Reply-To: from "Mark J. Taylor" at Dec 28, 94 02:34:31 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 772 Sender: hackers-owner@freebsd.org Precedence: bulk > 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.