Keyboard check under UNIX Sys V?
Guy Harris
guy at sun.uucp
Thu Oct 2 16:19:25 AEST 1986
> > > 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 at sun.com (or guy at sun.arpa)
More information about the Comp.unix.wizards
mailing list