Date: Thu, 29 Dec 1994 20:52:55 +0800 (HKT) From: John Beukema <jbeukema@HK.Super.NET> To: dufault@hda.com Cc: FreeBSD-questions <FreeBSD-questions@freefall.cdrom.com> Subject: kbhit() Message-ID: <Pine.SUN.3.91.941229204626.22386A-100000@is1.hk.super.net>
next in thread | raw e-mail | index | archive | help
In view of the interest in this question, I am enclosing a very simple and elegant solution to the problem sent by Peter Dufault which works fine in all tty modes. Thanks to all who responded. jbeukema #include <stdio.h> #include <sgtty.h> int kbhit(void) { int n; if (ioctl(fileno(stdin), FIONREAD, &n) == -1) n = 0; return n != 0; } Peter -- Peter Dufault Real Time Machine Control and Simulation HD Associates, Inc. Voice: 508 433 6936 dufault@hda.com Fax: 508 433 5267 ++++ Formerly hd@world.std.com. E-mail problems? Tell hdslip@iii.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.941229204626.22386A-100000>