Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!hc!beta!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.bugs.4bsd Subject: Re: read() from tty has fencepost error Message-ID: <6055@brl-smoke.ARPA> Date: Sun, 5-Jul-87 15:22:20 EDT Article-I.D.: brl-smok.6055 Posted: Sun Jul 5 15:22:20 1987 Date-Received: Sun, 5-Jul-87 22:38:21 EDT References: <648@haddock.UUCP> <6040@brl-smoke.ARPA> <13048@topaz.rutgers.edu> <1325@crash.CTS.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <1325@crash.CTS.COM> ford@crash.CTS.COM (Michael Ditto) writes: > [When EOF is received] all the characters waiting to be read are > immediately passed to the program, without waiting for a new-line, > and the EOF is descarded. ... This is of course nonsense, because the characters are NOT necessarily "passed to the program". (What program? Terminal I/O proceeds asynchronously, and there is no telling in advance which process will ultimately read the terminal input.) Typical UNIXy terminal handlers have a "canonical" input queue and a "raw" queue; in "cooked mode" (ICANON on), characters are passed from the canonical queue to the raw queue by a canonicalization gnome that "knows" that a newline or an EOF (also an EOL in System V) delimits a chunk of input (so that the chunk is immune to a subsequent char-erase or line-kill). In order to keep track of chunk ("line") boundaries in the absence of a newline, it is traditional to store a special "delimiter" marker in the input queue. There is an earlier section of the TERMIO spec that mentions line delimiters. The above quotation from the manual (same as in the SVID) is incomplete (as well as erroneous), in that it does not specify the boundary behavior of delimiters (i.e., the phenomena Ron reported on). >This is the way UNIX has always worked, except for Berkeley's versions, ... I dispute that. It MAY be the way that the USG 3.0 and derivative terminal handler (the "termio" one) has always worked.