Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!decvax!genrad!mit-eddie!godot!harvard!seismo!brl-tgr!gwyn
From: gwyn@brl-tgr.ARPA (Doug Gwyn )
Newsgroups: net.unix-wizards
Subject: Re:  Scanning stdin with no pause
Message-ID: <6678@brl-tgr.ARPA>
Date: Thu, 20-Dec-84 03:53:18 EST
Article-I.D.: brl-tgr.6678
Posted: Thu Dec 20 03:53:18 1984
Date-Received: Sun, 23-Dec-84 01:20:42 EST
References: <6674@brl-tgr.ARPA>
Organization: Ballistic Research Lab
Lines: 16

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