From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6058 invoked by alias); 18 Jul 2017 22:41:59 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 6014 invoked by uid 89); 18 Jul 2017 22:41:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:8.12.10, H*F:D*cornell.edu, pin X-HELO: limerock01.mail.cornell.edu Received: from limerock01.mail.cornell.edu (HELO limerock01.mail.cornell.edu) (128.84.13.241) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jul 2017 22:41:53 +0000 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock01.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id v6IMfpMK004268 for ; Tue, 18 Jul 2017 18:41:51 -0400 Received: from [192.168.0.4] (mta-68-175-129-7.twcny.rr.com [68.175.129.7] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id v6IMfoSh022442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 18 Jul 2017 18:41:51 -0400 Subject: Re: fflush(NULL) clobbers input streams To: cygwin-apps@cygwin.com References: <87k2376jck.fsf@Rainer.invalid> <20170718095456.GC26902@calimero.vinschen.de> <20170718105109.GD26902@calimero.vinschen.de> <87fudtlfen.fsf@Rainer.invalid> From: Ken Brown Message-ID: Date: Tue, 18 Jul 2017 22:41:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87fudtlfen.fsf@Rainer.invalid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00046.txt.bz2 On 7/18/2017 3:21 PM, Achim Gratz wrote: > Corinna Vinschen writes: >> Oh, and a plain C testcase, of course... > > Call that fflush.c: > > --8<---------------cut here---------------start------------->8--- > #include > int > main(int argc, char **argv) > { > char buf[1024]; > int i; > char *bp = buf; > while (1) { > while ((i = getc(stdin)) != -1 > && (*bp++ = i) != '\n' > && bp < &buf[1024]) > /* DO NOTHING */ ; > *bp = '\0'; > fprintf(stdout, "%s", buf); > fflush(NULL); > if (i == -1) > return 0; > bp = buf; > } > } > --8<---------------cut here---------------end--------------->8--- > > Then run: > > gcc fflush.c -o fflush > cat fflush.c | ./fflush 2>/dev/null > fflush.out > diff fflush.c fflush.out > > If things are working, fflush.c and fflush.out should be identical. > Currently only the first line makes it into fflush.out on Cygwin. I've checked that the 2017-03-08 snapshot is good and the 2017-03-10 snapshot is bad. I'll bisect further when I get a chance, but maybe that's already enough to pin down the problem. Ken