Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!decvax!decwrl!sun!shannon From: shannon@sun.uucp (Bill Shannon) Newsgroups: net.unix-wizards Subject: Re: 4.2bsd eof flag in stdio Message-ID: <1797@sun.uucp> Date: Mon, 19-Nov-84 18:11:06 EST Article-I.D.: sun.1797 Posted: Mon Nov 19 18:11:06 1984 Date-Received: Tue, 20-Nov-84 07:28:22 EST References: <1697@ucf-cs.UUCP> <1796@sun.uucp> <5867@brl-tgr.ARPA> Organization: Sun Microsystems, Inc. Lines: 42 > fread() returns 0 if there are 0 characters left in the terminal > input queue when the ^D is typed. What would you have it do? Try this program on your favorite version of stdio: #include char buf[256]; main() { register int n; while (n = fread(buf, 1, sizeof buf, stdin)) fwrite(buf, 1, n, stdout); printf("got EOF\n"); } Run it and type (e.g.): testing 1 2 3 ^D another test Where ^D is your EOT character. If the program terminates when you type ^D then your stdio works properly. The 4.1 version of stdio would "eat" the ^D and echo the first and third lines. It would only terminate if you typed ^D twice in a row. > If the 4.2BSD fread() was buggy, it should have been fixed rather > than introducing a significant incompatibility with other STDIOs. Making EOF sticky was the fix. It seemed like the right thing to do; the incompatibility was unfortunate. If you have a fix to fread (filbuf, actually) that both fixes this bug and avoids the incompatibility then please send it to me and/or post it to the net. If this works properly in System V I would be interested to hear that as well. Bill Shannon Sun Microsystems, Inc.