X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:references:in-reply-to:content-type:content-transfer-encoding;
	 q=dns; s=default; b=HIjnsp37dAemaBjA5FIK2k1E3bpMslI93sHO0mVJu0J
	FIEIXVlb179c6WzzoKp12OLniRScvYVL4hsMJLlefcBlAKFhyYgCkUOsk49lxYpp
	uqbD1LQU73/kCZVNQMsrwS8rQEoxybeB5gC6V131zrNlgp5qL16f7bNB3Ssxl/0E
	=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:references:in-reply-to:content-type:content-transfer-encoding;
	 s=default; bh=N9i+F1xkY2nn7+ed2VCJOs5DluY=; b=nLM8cPyPXrV9zbI15
	TBLhEJarCfZYsIa+kmDWNYadaQ1R9Yd1gaFg5Cb84PLIMKjh0ZmFHwLyyKS/Hbrm
	iCwwea67R0YZ65vlKAZUvLmVvMue1TeqIxZheO8BgOoX8on3k7RhTGXf2Dbm0TSo
	cMjg/5wq3EMn+jgC7L/Y9ieJmQ=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_05,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2
X-HELO: limerock01.mail.cornell.edu
X-CornellRouted: This message has been Routed already.
Message-ID: <54F0B3D2.8090804@cornell.edu>
Date: Fri, 27 Feb 2015 13:13:38 -0500
From: Ken Brown <kbrown@cornell.edu>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: freopen/fread/popen bug
References: <CAKVG1_qobJxAZSeZDozsGb7pb3ugYk_AgmEJXU-wRt+ifhf-QA@mail.gmail.com>
In-Reply-To: <CAKVG1_qobJxAZSeZDozsGb7pb3ugYk_AgmEJXU-wRt+ifhf-QA@mail.gmail.com>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes

On 2/27/2015 11:20 AM, A L wrote:
>> I think that would create an unacceptable performance penalty for the child process.
>
> The child process would not be affected at all!  FILE* will be
> unbuffered only in your
> application, yet "cat" will read from a file descriptor "1" (and may
> or may not apply any
> buffering on top of it, such as FILE*, on its own).  Since you are
> going to read only a few
> bytes out of "f" and leave the rest to "cat" (per your example), there
> is no performance
> penalty;  in fact there will be some gain not to pre-fill a buffer for
> "f" (which you don't need
> anyways).
>
> Also, you can just use basic unix IO (read() vs. fread()), and call
> lseek(1,0,SEEK_SET)
> prior to popen().  This way, there's no user-level buffering and file
> position is consistent with
> your actions and expectations.

Thanks (and thanks to Corinna and Eric) for correcting my misconceptions.  We 
have several viable solutions now, and I'm working with the upstream maintainers 
to decide which one to use.

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

