From owner-freebsd-hackers Wed Dec 28 14:03:25 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id OAA07277 for hackers-outgoing; Wed, 28 Dec 1994 14:03:25 -0800 Received: from cs.weber.edu (cs.weber.edu [137.190.16.16]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id OAA07269 for ; Wed, 28 Dec 1994 14:03:23 -0800 Received: by cs.weber.edu (4.1/SMI-4.1.1) id AA05369; Wed, 28 Dec 94 14:57:12 MST From: terry@cs.weber.edu (Terry Lambert) Message-Id: <9412282157.AA05369@cs.weber.edu> Subject: Re: how to emulate kdhit()B? To: mtaylor@gateway.cybernet.com (Mark J. Taylor) Date: Wed, 28 Dec 94 14:57:11 MST 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.4dev PL52] 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? > >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.