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.
-Peff