This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stderr outputs veerrrryyy slowly

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:

#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

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?


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]