Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6D9911F4DD for ; Sun, 27 Aug 2017 02:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751190AbdH0CGf (ORCPT ); Sat, 26 Aug 2017 22:06:35 -0400 Received: from avasout07.plus.net ([84.93.230.235]:60859 "EHLO avasout07.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbdH0CGe (ORCPT ); Sat, 26 Aug 2017 22:06:34 -0400 Received: from [10.0.2.15] ([147.147.86.16]) by avasout07 with smtp id 226X1w0090M91Ur0126ZGE; Sun, 27 Aug 2017 03:06:33 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=CrLPSjwD c=1 sm=1 tr=0 a=dubYQqM3tRRTmV8xSh8cXQ==:117 a=dubYQqM3tRRTmV8xSh8cXQ==:17 a=IkcTkHD0fZMA:10 a=IasFUMneo_ByyoNf3xIA:9 a=QEXdDO2ut3YA:10 X-AUTH: ramsayjones@:2500 Subject: Re: cat-file timing window on Cygwin To: Adam Dinwoodie , Jeff King Cc: git@vger.kernel.org, Johannes Schindelin References: <20170825112529.GA10378@dinwoodie.org> <20170825150819.agxvbjytom7ao6n6@sigill.intra.peff.net> <253bf111-4e8a-54b7-6e39-2908270aa357@ramsayjones.plus.com> <20170826185337.hrcswjuunon54kgj@sigill.intra.peff.net> <20170826211104.GC10378@dinwoodie.org> From: Ramsay Jones Message-ID: Date: Sun, 27 Aug 2017 03:06:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170826211104.GC10378@dinwoodie.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 26/08/17 22:11, Adam Dinwoodie wrote: > 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 >> >> 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! This is apparently fixed in cygwin v2.8.3 [see commit 78ade082fe, ('Revert "errno: Stop using _impure_ptr->_errno completely"', 19-07-2017), commit 9cc89b0438 ("cygwin: Use errno instead of _impure_ptr->_errno", 19-07-2017), commit a674199fc9 ("cygwin: Bump DLL version to 2.8.3", 19-07-2017) and commit d2ae2f00b8 ("cygwin: add fflush fix to release notes", 19-07-2017)]. I haven't had a chance to try v2.8.3 yet (it's 3am and I'm about to go get some sleep). ATB, Ramsay Jones