Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Sun, 22 Jun 2003 11:35:12 -0400
From: Christopher Faylor <cgf-rcm@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: stderr outputs veerrrryyy slowly
Message-ID: <20030622153512.GB28328@redhat.com>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <3EF099C8.8FDEC855@dessent.net> <3EF09ED6.F4943C46@dessent.net> <3EF0B792.40204@cygwin.com> <3EF0BFA2.99CCC92A@dessent.net> <3EF26B27.1020203@cygwin.com> <20030620021155.GA19483@redhat.com> <3EF553B3.68EAF8FA@dessent.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <3EF553B3.68EAF8FA@dessent.net>
User-Agent: Mutt/1.4.1i

On Sat, Jun 21, 2003 at 11:58:59PM -0700, Brian Dessent wrote:
>Christopher Faylor wrote:
>>This crops up on the cygwin list from time to time.
>>
>>IIRC, if you use 'setbuf(f, NULL)' in newlib (as is the case for
>>stderr), it causes newlib to flush on every character.  I submitted a
>>patch to fix this behavior many years ago but it was rejected.  I think
>>the rationale was basically a "This isn't broken.  We're allowed to do
>>this" but I don't really recall exactly why the patch was rejected.
>
>Hmmm.  Well, I managed to come up with this minimal testcase:

There is no need for a test case.  I already mentioned that this is a
known issue and pinpointed where the problem lies.

>#include <stdio.h>
>
>int main(int argc, char **argv)
>{
>    char *msg = "This is a test! ", *ptr;
>    int i;	
>
>    for(i = 0; i < 100; i++) {
>        for(ptr = msg; *ptr; ptr++) {
>            fputc(*ptr, stderr);
>        }                            	
>    }
>}
>
>Running the above with CYGWIN=tty
>real    0m15.806s
>user    0m0.030s
>sys     0m0.010s
>
>Without CYGWIN=tty
>real    0m0.078s
>user    0m0.030s
>sys     0m0.020s
>
>Should it really take almost 16 seconds to print 1600 characters to
>stderr?
>
>Furthermore, if you change 'stderr' to 'stdout' above, the problem no
>longer happens, regardless of the setting of tty in $CYGWIN.  So it's
>specific to stderr.
>
>Can anyone make heads (or tails) of this now?

Read my original message.  stderr does not buffer its output.  stdout does.

cgf
--
Please use the resources at cygwin.com rather than sending personal email.
Special for spam email harvesters: send email to aaaspam@sourceware.org
and be permanently blocked from mailing lists at sources.redhat.com

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

