Scanning stdin with no pause

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Thu Dec 20 18:53:18 AEST 1984


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

A groady way to accomplish this on any UNIX is to use a second process
that communicates with the controlling process via a pipe.

> I need to put the character back on to stdin or 
> only look at stdin and not take the character from the buffer.

ungetc() does this (only one character of pushback).  If you need more
pushback, see the buffered input routines in Software Tools.



More information about the Comp.unix.wizards mailing list