delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/02/27/13:14:01

X-Recipient: archive-cygwin AT delorie DOT 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 AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT 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 AT cornell DOT 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 AT cygwin DOT com
Subject: Re: freopen/fread/popen bug
References: <CAKVG1_qobJxAZSeZDozsGb7pb3ugYk_AgmEJXU-wRt+ifhf-QA AT mail DOT gmail DOT com>
In-Reply-To: <CAKVG1_qobJxAZSeZDozsGb7pb3ugYk_AgmEJXU-wRt+ifhf-QA@mail.gmail.com>
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019