^D and <EOF>

utzoo!decvax!ucbvax!c-alayto at CCA-UNIX utzoo!decvax!ucbvax!c-alayto at CCA-UNIX
Wed Jul 22 06:59:41 AEST 1981


From: c-alayto at CCA-UNIX (Alexis Layton)

What Dave Crocker <dcrocker at udel> and others have called a bug is really
nothing of the sort.  My understand of UNIX typing conventions is as follows:
Most line terminating characters (i.e. newline) insert themselves into the
input buffer before causing the read(2) to return.  The function of ^D (or
for those of you who have changed it, whatever tchars.t_eofc is) is to cause
read(2) to return with the contents of the buffer WITHOUT inserting itself.
In the case that the buffer is empty, then read(2) returns 0, which is the
proper definition of end of file.  This is totally consistent and (I believe)
well documented.  (I only have the 4bsd documentation here, so I can't speak
for all UNICES.)




More information about the Comp.unix.wizards mailing list