Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.unix-wizards Subject: Re: Scanning stdin with no pause Message-ID: <4937@utzoo.UUCP> Date: Wed, 16-Jan-85 12:00:34 EST Article-I.D.: utzoo.4937 Posted: Wed Jan 16 12:00:34 1985 Date-Received: Wed, 16-Jan-85 12:00:34 EST References: <6674@brl-tgr.ARPA> <6678@brl-tgr.ARPA>, <22@qfdts.OZ> Organization: U of Toronto Zoology Lines: 28 > >> I am working with V7 UN*X. I need a way to scan the standard input > >> stream for a character, but not wait. > > > >This is not supported by 7th Edition UNIX. You need to add something > >to your kernel to do this directly; the Rand Corp. empty() call has > >been distributed by USENIX a long time ago, and more recent approaches > >include VTIME,VMIN in AT&T UNIX Systems III & V and select() in 4.2BSD. > > VTIME and VMIN index the control character array in the termio structure > of USG systems. They appear to be potentially very usefull, but I have > been unable to locate any printed documentation on how to manipulate > c_cc[VTIME] and c_cc[VMIN] to achieve a non-blocking read. Can anyone > enlighten me please? As I understand them, VTIME and VMIN cannot be used to do non-blocking reads, contrary to the second excerpt above. What they can be used to do is to make raw mode more efficient when you have some idea of what to expect in the way of input -- you can make raw mode deliver more than one character per system call, by having it wait for a specified time or a specified number of characters (whichever comes first). But if absolutely nothing is received, you still hang waiting for something. The VTIME setting is not a timeout when waiting for the first character, it is a timeout when waiting for *more* characters. Caveat: I'm not an expert on the SysV terminal driver. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry