delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/06/20/13:51:08

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D946B3858C2C
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=cornell.edu
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cornell.edu
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=Nn9kZhcE89EK4UnbhzDvwjgFkscXhXqBXrXoSlIumFBSK2bUSConYpgOJVCtiipVU7bRXb99VP+6k2Pd0qmftkUI8li0D4qgz5O0gSaanSlq2I8RuPf/FlrrKZMd0Doo98nyuunkryTAn/zu9wBQtfDFZF2epDJoJZfg6uZTOJ6ZLOJ2Dsq0lHnL8vR+ZdDmkWbQlp4v6nZ3+ijHJEROls6iuvugacZNDVJzbIvKW5OsFicFuEVN+ER9fHTb+AZG9f9KA9Rt9e8oXs5gOdrSEWc8Z2S4i+x16HFu+9aMG1DHLftZddrSOkkHlxyejNUrvlMYzDW/6h4E+pUKlMfoHA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=LT/2FesY9zrLL+KkrrDh4ILvhRr6Ha5tx3v78bh5Djo=;
b=nypNLTg63jP2AWN7XU3JM7WjyiQ6ADBUmticqWi0GFEvjCavNDxQ0xigCntwNnqsXaluIWc4c3GHZRaVMv8KS9gcOPMH6wcI7KZTFazQAYDcA/8rlMl6t8t56/VWHcjsVFLb/d/N1XRS3+ladyyYijP+oup5sRvFgePfl7+hmRJN0OVCfLwvucXobgAVDDPDZJ2Svw9chqBhg7ONkcfNRBb3fyK4m6w6AJbdflhSEyX4p5wRkVIfd+SPbYvHF3uRvoFqVqegjrfkQmYT6fJmLBBA+C1Mt65xR5saJlTq6kw28/pUUdQLsFakX8zTESsSyYS+tgGlL9XZUBEfT4q3tw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu;
dkim=pass header.d=cornell.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu;
s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=LT/2FesY9zrLL+KkrrDh4ILvhRr6Ha5tx3v78bh5Djo=;
b=XrlW0we19T41DgDyw9c1MBvymXeHb4wxp/AaGLft6vMOdNj5LMsCLXBRiL4gK5r9IipV2i9bl6zPojK54qyxXSb3E7wiD5A4ytZhMZrMNr6Qa8iYPzuemfeGx1eAEIXwqWfAbfDObwYkFgjCANhcOlEGlidL2FppppInJVrwnGQ=
Authentication-Results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=cornell.edu;
Message-ID: <7a999f10-eda4-c9e5-725a-2d3e3524eef8@cornell.edu>
Date: Mon, 20 Jun 2022 13:50:23 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Subject: Re: Bug in Control-d handling?
To: moss AT cs DOT umass DOT edu, cygwin AT cygwin DOT com
References: <827e2006-2aae-9f7f-9c3f-eef3a7c6e793 AT cornell DOT edu>
<20220620175935 DOT 924a49feb13156f1a3cf3da4 AT nifty DOT ne DOT jp>
<20220620192223 DOT 2e0a084a7c093939b1c7c8d6 AT nifty DOT ne DOT jp>
<5c548a4c-b7ea-b7e0-6ab6-ea0e94ce66a1 AT cornell DOT edu>
<0ce1465e-b9fd-8794-8707-ee4b2ff4cbb4 AT cs DOT umass DOT edu>
From: Ken Brown <kbrown AT cornell DOT edu>
In-Reply-To: <0ce1465e-b9fd-8794-8707-ee4b2ff4cbb4@cs.umass.edu>
X-ClientProxiedBy: BL0PR02CA0023.namprd02.prod.outlook.com
(2603:10b6:207:3c::36) To BN7PR04MB4388.namprd04.prod.outlook.com
(2603:10b6:406:f8::19)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 392b8176-9771-4091-739c-08da52e55abc
X-MS-TrafficTypeDiagnostic: BN6PR04MB0501:EE_
X-Microsoft-Antispam-PRVS: <BN6PR04MB0501042C4CC8E670CB51A820D8B09 AT BN6PR04MB0501 DOT namprd04 DOT prod DOT outlook DOT com>
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: BSWbw+T9l7Ks2ur24Ekpz2O8KKn8HEljHODHhw3+svTuuSu95pqAD6oPuGGaW+IXRjByIvqryte7G03CFMk3Q7pklvWKvgRzj/+WbBC12HEmeEqrIxz4Pi7hNb+SMz9SyS04tPn3yYLZ/cXGDzlfSjwbHoot7XySmwQd6N3xkUgBsJYgAIq32q87/W3hKLKU1pYuv/qsTgro1bMkwm/UMVJozcWLT5qkWohHz3JhzOBLtdRjipZeWGTLhpT16jo+xcTb/DxIFsoX57jb1PiIXRTXDHJZ2Se3Oypc6PWCVNKASXKU1j/7aSxgMQ7/w75fo4Nrx/UoMTCTM1bDc8s+2Jja5sckL4FO6Wcw6MeCsdDHS8abKdOJ2bdga/TXMKhxjzuXNMN8DBetUR8lVIhmRtaMn8aqUlFZrtI3BjvsXJAI0vEuLckkc6N+xz0kDtwXIEPiGa+5EPAH3aVCOszKS3TyEV6bMr8G8nVSh0WXnIE0iZdTiP/zzhHkJojbamGQANvBSiGbKl5f5kwxaavDYBCyO5wlR5bOVDUCpOUo3+GNpcd9vS7l13grXDvrFP77C2bSUm+kKt+1bWMvv560Fb4EuBBD+Lxwa3UjlTcV1yblQjXIHxGWWKPJm/r4cBR9p0Nh68hvPJ3S9P2HXIpBePKrKrmLyXBiEU5UFx1aWkv69e49YExG4Whxb4W98bSGhphicwC4oeCUcMEOMjuGBYwNiLJTsSqv0riaQaT2FKeScMgV+gcqqARRMuyewWa4
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230016)(4636009)(366004)(136003)(39860400002)(346002)(396003)(376002)(53546011)(6506007)(31696002)(6486002)(86362001)(6512007)(66946007)(2906002)(8676002)(66476007)(2616005)(8936002)(3480700007)(66556008)(316002)(41320700001)(38100700002)(478600001)(186003)(83380400001)(41300700001)(31686004)(786003)(75432002)(5660300002)(36756003)(43740500002)(45980500001);
DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2
X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c1kxdG9qVFg1MVRmS0J2V0pDcGwycHdiL0tqODU3Ulp2Q1BIemplSk9qTGdZ?=
=?utf-8?B?ZldwMU1DbVNlWDJva0tRdUMyVloxRnZ4bDJ2TmM4Zm1EbVB5YTltejdnMmpL?=
=?utf-8?B?SGRSNjhRdlIxSnhva3UrcGlKamFCUTY5MGo1NWdxVzdFRHNTeUZqV2hZeWY5?=
=?utf-8?B?azhHTGI0b2FMTVg3QStrMUErSG5GbUxZaUVKcHg4ZzhQQThwK2x3eXRocE9n?=
=?utf-8?B?cWlydE9RMzVTakxZQnArR01ZU2ZYVzk1b1lmZHozazlrV1JVeThHcHBKd0Fp?=
=?utf-8?B?cUFDWktiWXJERjd0QkhOMzFhS1g0Q3BYTysvb25TZTM4Ym8yN0toeGxjbS9i?=
=?utf-8?B?MmhoM1JyMlg4UEYvZStXMmg4WEZYTXkrUmJtemRZM1pyeUtiYTQ2SkhDaFRS?=
=?utf-8?B?dHVyWitGeWRuZFFMcko0ZFZoNE1EbVJBcEw0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0alpKdUtycnFNNWpISmJVaXNhN2ZFY2hTeGhRTE1V?=
=?utf-8?B?MmxFUmFIYm5VN2JKU0Z6U2VtZDNOMkdqRGVVa3orUi9COUpKemVXRjQ4TWNJ?=
=?utf-8?B?b0FNWGYyczA5ZHJkeWxpaGlGV2UzWXRyajlRMGY0cTdLMCtWSHdyMHh5M0Nj?=
=?utf-8?Q?eAMGBPE+bK2MarhJbPna1qbmUKxD4pNSy0tf4K5m9YIj7?=
X-MS-Exchange-AntiSpam-MessageData-1: SSszdGWrMmdwag==
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: 392b8176-9771-4091-739c-08da52e55abc
X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2022 17:50:25.0728 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: OZL3tfi/NuxxBG6O5GntkDDF2lc8lYgjrtG4cKjkudFOGIyZy9lTFvEKMlG6fn8qdYwh6KxM0fwsmOtowJiesg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0501
X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, NICE_REPLY_A,
SPF_HELO_PASS, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no 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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 25KHp8NY014122

On 6/20/2022 9:53 AM, Eliot Moss wrote:
> Good idea to wait for Corinna.  I did a smidge of research, looking through
> the Wikipedia page on the POSIX terminal interface.  It suggests that this
> part was largely borrowed from System-V, so that may explain what we see in
> newlib.  And looking up the POSIX spec, it says this:
> 
> "Special character on input, which is recognized if the ICANON flag is
> set. When received, all the bytes waiting to be read are immediately passed to
> the process without waiting for a <newline>, and the EOF is discarded. Thus,
> if there are no bytes waiting (that is, the EOF occurred at the beginning of a
> line), a byte count of zero shall be returned from the read(), representing an
> end-of-file indication. If ICANON is set, the EOF character shall be discarded
> when processed."
> 
> This suggests that indeed control-D will need to be typed twice before a
> blocking read on a terminal with ICANON will appear to be at eof.  I guess we
> can consider getchar to be (almost) like a read of size 1, except where read
> would return 0, getchar returns -1.
> 
> The quoted text above implies that the second control-D will set the
> end-of-file indicator.  So I agree that it looks like the ifndef should be
> removed.  And of course, wherever we said control-D, EOF should be implied (it
> is normally control-D, but the user can change which character is associated
> with the EOF semantics).

I would frame the issue slightly differently, since this is not just about 
terminals; the code we're discussing applies to any file.  Suppose EOF has been 
seen in a call to one of the stdio input functions.  Prior to commit 1f8f7e2d, 
any further calls to those functions would immediately return EOF.  Since that 
commit, however, another attempt is made to read, and the EOF indicator for the 
file is turned off if input is found.  In many cases (e.g., an ordinary disk 
file), this second read will still return EOF.  In other cases (e.g., a 
terminal), the second read might block if there's still no input available.

Ken

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019