git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Dinwoodie <adam@dinwoodie.org>
To: Jeff King <peff@peff.net>
Cc: Ramsay Jones <ramsay@ramsayjones.plus.com>,
	git@vger.kernel.org,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: cat-file timing window on Cygwin
Date: Sat, 26 Aug 2017 22:11:04 +0100	[thread overview]
Message-ID: <20170826211104.GC10378@dinwoodie.org> (raw)
In-Reply-To: <20170826185337.hrcswjuunon54kgj@sigill.intra.peff.net>

On Sat, Aug 26, 2017 at 11:53:37AM -0700, Jeff King wrote:
> On Sat, Aug 26, 2017 at 01:57:18AM +0100, Ramsay Jones wrote:
> 
> > > diff --git a/run-command.c b/run-command.c
> > > index 98621faca8..064ebd1995 100644
> > > --- a/run-command.c
> > > +++ b/run-command.c
> > > @@ -641,7 +641,6 @@ int start_command(struct child_process *cmd)
> > >  	}
> > >  
> > >  	trace_argv_printf(cmd->argv, "trace: run_command:");
> > > -	fflush(NULL);
> > >  
> > >  #ifndef GIT_WINDOWS_NATIVE
> > >  {
> > 
> > I suspect not, but I can give it a try ...
> > 
> > ... oh, wow, that works! Ahem. (Hmm, so it's flushing stdin?!)
> 
> Interesting. I find it a little hard to believe there's so obvious a bug
> as "fflush(NULL) flushes stdin", but well...that's what it seems like.
> 
> If that's truly what it is, this is the minimal reproduction I came up
> with:
> 
> -- >8 --
> #include <stdio.h>
> 
> int main(void)
> {
> 	char buf[256];
> 	while (fgets(buf, sizeof(buf), stdin)) {
> 		fprintf(stdout, "got: %s", buf);
> 		fflush(NULL);
> 	}
> 	return 0;
> }
> -- 8< --
> 
> If this really is the bug, then doing something like "seq 10 | ./a.out"
> would drop some of the input lines.

...yep.  It does.  Specifically, I consistently only get the firsts
line:

    $ seq 10 | ./a.exe
    got: 1
    
    $ 

If I introduce a delay between the lines of stdin (which I tested by
just typing stdin from the keyboard), it works as expected.

Looks like this one will need to go to the Cygwin mailing list; I'll
take it there shortly.  Thank you all for your help getting this far!

  reply	other threads:[~2017-08-26 21:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 11:25 cat-file timing window on Cygwin Adam Dinwoodie
2017-08-25 15:08 ` Jeff King
2017-08-26  0:57   ` Ramsay Jones
2017-08-26 15:43     ` Adam Dinwoodie
2017-08-26 18:53     ` Jeff King
2017-08-26 21:11       ` Adam Dinwoodie [this message]
2017-08-27  2:06         ` Ramsay Jones
2017-08-27 11:33           ` Adam Dinwoodie
2017-08-27 15:47             ` Ramsay Jones
2017-08-27 18:53               ` Jason Pyeron
2017-09-08 20:02               ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170826211104.GC10378@dinwoodie.org \
    --to=adam@dinwoodie.org \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).