Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.lang.c,comp.unix.questions
Subject: Re: Why can't stdin from a file be read by an overlay?
Message-ID: <6795@brl-smoke.ARPA>
Date: Sat, 5-Dec-87 10:04:47 EST
Article-I.D.: brl-smok.6795
Posted: Sat Dec  5 10:04:47 1987
Date-Received: Thu, 10-Dec-87 06:01:36 EST
References: <2775@tut.cis.ohio-state.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 13
Keywords: Unix,stdio
Xref: mnetor comp.lang.c:5754 comp.unix.questions:5216

In article <2775@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes:
>Suppose a program reads stdin, prompts the user for some infor-
>mation, and then execs (no fork) a process to finish prompting
>the user for other information.  There isn't a problem when the
>input is from a tty, however, if the input is redirected, say
>from a Bourne shell here document, the second process sees an
>EOF immediately.

Probably the input is being fully-buffered, which means that
the original has consumed more input than you intended, which
is lost when the exec() occurs.  The solution would be to use
setbuf() or setvbuf() to use unbuffered or line-buffered
input for stdin.  That should prevent stdio from reading ahead.