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:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=qddJnJGrpBmUY2DF+mMpUMU1K3Z9m GJ/yK854nCLx482PmXzTrK72hgeLAy55GmBumb21RgUJV4biNNJO7fxpGNB/ka8E bzCKyXy7dUQwdPjD7a8LN1OufM178FGNBfne75V/CiIgQmRUgZFOwjNJxNZZDudk FpGXJ59b7+gU74= 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:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=TfhHvJ5OD87XATNep8Xx4LxsBmk=; b=M8p 55oGHI1cWVNWGP1C35Ljyr3QK2OlQbg96Yo/qAoXqYYNTct6cI3NWr4lsb+ifSm2 jcfcYpYJZ8WQdXm/SrgxWh1gR7plVGhaEfQ6njvpy0A3tOa4WxCZOai1LUl+TtGk oP6sEvaGOHO46Gpc/rt0FZIP2vj9ZEohqixBI7tg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=3.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-lb0-f179.google.com X-Received: by 10.152.8.33 with SMTP id o1mr13700501laa.56.1425054076091; Fri, 27 Feb 2015 08:21:16 -0800 (PST) MIME-Version: 1.0 From: A L Date: Fri, 27 Feb 2015 11:20:55 -0500 Message-ID: Subject: Re: freopen/fread/popen bug To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 > 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. -- 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