Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!lll-crg!lll-lcc!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix,net.micro.att,net.unix-wizards Subject: Re: Keyboard check under UNIX Sys V? Message-ID: <7847@sun.uucp> Date: Thu, 2-Oct-86 02:19:25 EDT Article-I.D.: sun.7847 Posted: Thu Oct 2 02:19:25 1986 Date-Received: Sat, 4-Oct-86 10:45:18 EDT References: <30896@arizona.UUCP> <224@BMS-AT.UUCP> <592@imagen.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 41 Xref: watmath net.unix:9450 net.micro.att:1561 net.unix-wizards:19786 > > > What is the preferred way to determine if a key has been pressed > > > on the keyboard when running UNIX Sys V? ... > > ... > > tty.c_cc[VMIN]=0; /* wait for at least VMIN chars on read */ > > tty.c_cc[VTIME]=0; /* wait at least VTIME seconds/10 on read */ > > ioctl(0,TCSETA,&tty); > > > > saved = read(0,&c,1); > > ... > > Don't assume that this works for all System V UNIX implementations. > For example, Convergent Technologies CTIX on MegaFrame and MiniFrame will > block on the read! Somebody else claimed that the behavior of the tty driver under some circumstances, probably those with a MIN of 0, changed between S5R1 and S5R2. I don't know what version the CTIX you tried this on was based on, but the CTIX on the UNIX PC is alleged to be based mostly on S5R1. However, I happen to have the VAX sources for S5R1 and S5R2 (Version 1) handy (thank you, NFS), so I "diff"ed "/usr/src/uts/vax/io/tt1.c" and "/usr/src/uts/vax/io/tty.c" between S5R1 and S5R2. Lo and behold, the *only* difference between the two "tty.c" versions is the SCCS ID, and the only non-trivial differences between the two "tt1.c" versions are 1) the addition of the SWTCH character for shell layers and 2) the addition of some code to handle breaks a little differently. If somebody has evidence that S5R1 and S5R2 differ in the handling of MIN == 0 cases on *vanilla* S5 distributions (i.e., nobody made any changes to "tty.c" or "tt1.c"), I'd like to hear it. Otherwise, the differences are probably a function of somebody "fixing" their S5 to work the way S3 did. In S3, TIME was *never* a timeout whose clock started when the read was performed; the clock started only when a character arrived. Note that the SVID goes into some detail about the expected behavior for different cases of MIN, TIME, or both equal to zero, so if the read blocks in the above circumstance the system isn't SVID-compliant. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)