Scanning stdin with no pause

Henry Spencer henry at utzoo.UUCP
Thu Jan 17 03:00:34 AEST 1985


>     >>     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



More information about the Comp.unix.wizards mailing list