From owner-freebsd-questions Thu Dec 29 05:00:34 1994 Return-Path: questions-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id FAA18024 for questions-outgoing; Thu, 29 Dec 1994 05:00:34 -0800 Received: from is1.hk.super.net (jbeukema@is1.hk.super.net [202.14.67.232]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id EAA17699 for ; Thu, 29 Dec 1994 04:54:59 -0800 Received: by is1.hk.super.net id AA22753 (5.67b/IDA-1.5 for FreeBSD-questions ); Thu, 29 Dec 1994 20:52:55 +0800 Date: Thu, 29 Dec 1994 20:52:55 +0800 (HKT) From: John Beukema To: dufault@hda.com Cc: FreeBSD-questions Subject: kbhit() Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: questions-owner@freebsd.org Precedence: bulk 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 #include 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