From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-01.nifty.com (conssluserg-01.nifty.com [210.131.2.80]) by sourceware.org (Postfix) with ESMTPS id 6E8A93858C51 for ; Mon, 20 Jun 2022 10:22:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E8A93858C51 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from HP-Z230 (ak044095.dynamic.ppp.asahi-net.or.jp [119.150.44.95]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 25KAMOHA027624 for ; Mon, 20 Jun 2022 19:22:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 25KAMOHA027624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1655720544; bh=EtgTMMAXJqyrhwyI14QYUDogz1aJF9z9fmq5Tg7VeEg=; h=Date:From:To:Subject:In-Reply-To:References:From; b=Cx8sUhS7lhzc9G2yIruk8i4du73CLd+d3wJz5D1ArH+8KaSF3Vhx68auWEQLVm8It X9RTJnmiHnVrkeG6Q76i35yf2RCUPogrTt3lguSMWJLdZPdmqCPuAwIGmNtHRtkrKE N9ZIQzZ3YmwiXXDW+kZgqzPSU6PErU0OzPSsbz6iEKcY8q9UkN1ISXQNHAHt28O89E oqe+0ESBi20KUC93hwfjYj/NJGOvlrpOXXutkqqg+fHDkj7FRoyn3kQ8r7BrYxY3M7 sl++cXJ+aBqBI9I9Of5ADofo/5tQ84UsOh1F6UrPLCUYlqV/CnMM94/VaDBLEgJ6BV dSR9LUAQ8RYeA== X-Nifty-SrcIP: [119.150.44.95] Date: Mon, 20 Jun 2022 19:22:23 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Bug in Control-d handling? Message-Id: <20220620192223.2e0a084a7c093939b1c7c8d6@nifty.ne.jp> In-Reply-To: <20220620175935.924a49feb13156f1a3cf3da4@nifty.ne.jp> References: <827e2006-2aae-9f7f-9c3f-eef3a7c6e793@cornell.edu> <20220620175935.924a49feb13156f1a3cf3da4@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2022 10:22:46 -0000 On Mon, 20 Jun 2022 17:59:35 +0900 Takashi Yano wrote: > Isn't this a bug of newlib? Try following code. > > #include > > int main() > { > printf("%d\n", getchar()); > printf("%d\n", feof(stdin)); > printf("%d\n", getchar()); > return 0; > } > > If you press Ctrl-D at the first getchar(), the second getchar() > does not return EOF while it does in linux. > > The following patch seems to resolve the issue. > > diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c > index ccedc7af7..843163b7e 100644 > --- a/newlib/libc/stdio/refill.c > +++ b/newlib/libc/stdio/refill.c > @@ -47,11 +47,9 @@ __srefill_r (struct _reent * ptr, > > fp->_r = 0; /* largely a convenience for callers */ > > -#ifndef __CYGWIN__ > /* SysV does not make this test; take it out for compatibility */ > if (fp->_flags & __SEOF) > return EOF; > -#endif > > /* if not already reading, have to be reading and writing */ > if ((fp->_flags & __SRD) == 0) > > However, I am not sure what this #ifndef __CYGWIN__ is for. Ah, I confirmed that System V (Solaris 11.4) behaves like that. Does cygwin aim for System V compatibility??? -- Takashi Yano