Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sunybcs!boulder!hao!oddjob!gargoyle!ihnp4!cbosgd!osu-eddie!chemabs!rsh27 From: rsh27@chemabs.UUCP (Robert S. Hall) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Keyboard Input (Revised Question) ... Message-ID: <196@chemabs.UUCP> Date: Sun, 26-Jul-87 23:16:26 EDT Article-I.D.: chemabs.196 Posted: Sun Jul 26 23:16:26 1987 Date-Received: Tue, 28-Jul-87 01:45:42 EDT References: <1043@bucsb.bu.edu.UUCP> Reply-To: rsh27@UNIX14.UUCP (PUT YOUR NAME HERE) Organization: Chemical Abstracts Service, Columbus Ohio Lines: 13 Keywords: Keyboard Xref: mnetor comp.lang.c:3299 comp.unix.questions:3360 In article <1043@bucsb.bu.edu.UUCP> eap@bucsb.UUCP (Eric Pearce) writes: >I would like to write a routine that performs a repeated sequence of statements >(i.e. a loop) that would check for input from the keyboard and do something >according to what was typed in. Also, it would be able to continue doing the >loop regardless of whether or not anything was typed in from the keyboard. On a System V version of Unix you could open stdin using O_NDELAY (By the way on our Ultrix 1.2 system, in System V emulation mode, a program that uses O_NODELAY mode on the keyboard will cause a user to be logged off when it terminates.) On 4.[2,3] Berkley Unix you could use "ioctl(0,FIONREAD,&lngintvar);" this will return the number of characters that are ready to be returned by a read call in a long int variable named "lngintvar". See the "tty(4)" documentation for more information. 6