From nobody Tue Jan 9 13:55:07 2024 X-Original-To: standards@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T8XVz1SClz57Xcc for ; Tue, 9 Jan 2024 13:55:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T8XVy6hdVz54FN for ; Tue, 9 Jan 2024 13:55:06 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704808506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Njz3cuXesuzchCWeew4tbwVe8P9J7DqUonaDpn8lPlg=; b=bLY8X9KZoKhg+avu3NCB9568sTmWGwQPkwl1XRXEF0B9Ynj35oMVb4nqOTw5XnKR6gPW4V vLNAg2mk6jywfZVcDFJiK2lGyMRTMwjpRKxCIQX+vYICwdCqyXy2wmYiwCtOtR4LgJRAjf 2jTpFcuJXPEsZO+uXWthNPmVzKGmSEwVDVEOo5HKzmqP8YfNlLX5Y0cvq7rNv1sfe7iOxx QackiTmFuijHasz0IYHZm+fDbfdB9dwp3ZXTQeSU/Z+mpykoUvb14ziGIiIY/hwlH9zV+x v/j6JotVyOgzmgdQdBfN4rPmsIuarD3DhZ9SUIAE6KaUcqatgKp0hNaOGaJkUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704808506; a=rsa-sha256; cv=none; b=awmNfqnrPX7jaJNTuh9tDrsqBtIjCgcUu/iiN1ke6ec51MlzY41DpSss+04D37k9IO5M/P rFrJZQfyxI6r7N9sZW0Es506dDbfSnTxp8b3B35rz/0id3FmFLwZAAs8u+4/ZCigbteV5s I1QV1xJl9gncNa0E8Vuo8ZLwNIta8m8MKT7nAHj6OztDieDNL/WMCsz9x7Wf9dUs5nCyRs io34rQw0elblLRbqs7A32u+Tf+KEG8y7pXwGHZq3f3btHbB5bL/HAypUHCaJT1X7cNevKF XbA2l9WFCt3z32lPvb6JhEzEc4Va4Sobp2H62BLajh8Aj7oqGJpTr9t6M5EI2g== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T8XVy5nf2ztMT for ; Tue, 9 Jan 2024 13:55:06 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 409Dt6sF003860 for ; Tue, 9 Jan 2024 13:55:06 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 409Dt6MK003859 for standards@FreeBSD.org; Tue, 9 Jan 2024 13:55:06 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 276220] tty_disc canonical input processing: suprising behavior of the EOF cchar Date: Tue, 09 Jan 2024 13:55:07 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: 14.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: hym2209268914@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-standards@freebsd.org X-BeenThere: freebsd-standards@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276220 Bug ID: 276220 Summary: tty_disc canonical input processing: suprising behavior of the EOF cchar Product: Base System Version: 14.0-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: hym2209268914@gmail.com The naive programmer, having some experience with the tty, and having read = the POSIX 2017 may assume that upon input of the EOF cchar just throws it self = away and flushes the dumb line editor's contents to the read queue. That's not what happens in FreeBSD. If a canonical input processing program, like cat(1), chooses to repeatedly read() with nbyte set to 5 bytes, when t= he user presses 'h' 'e' 'l' 'l' 'o' '^D' successively, the read queue will be 6 bytes as reported by FIONREAD. The first read() will complete as expected, returning 5 and decreasing read queue to 1 byte. but when it finishes echoi= ng the chars and read() again, the ttydisc would throw away the 1 byte in the input queue and immediately return 0! The program would then terminate, muc= h to the surprise of the naive programmer. That is, when program read() the input queue when the sole character there = is an EOF, the kernel would incorrectly return 0 rather than throw it away and wait for input. The EOF or canonical mode should not affect the processing = of the input queue, only the dumb line editor.=20 Normally read() returning 0 in canonical input processing should only happen when user have just pressed EOF/EOL/EOL2 and pressed EOF again. If I stop the program via debugger, hit 'hello^D', switch to -icanon via st= ty -f, then continue the program, this weirdness will not happen. The latest Linux kernel does not have this problem.=20 NetBSD kernel also has this problem. --=20 You are receiving this mail because: You are the assignee for the bug.=