Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!hao!seismo!harvard!wjh12!genrad!mit-eddie!godot!ima!ISM780!bruce From: bruce@ISM780.UUCP Newsgroups: net.unix-wizards Subject: Re: Re: 4.2bsd eof flag in stdio Message-ID: <12@ISM780.UUCP> Date: Thu, 29-Nov-84 00:31:17 EST Article-I.D.: ISM780.12 Posted: Thu Nov 29 00:31:17 1984 Date-Received: Sun, 2-Dec-84 04:52:30 EST Lines: 42 Nf-ID: #R:desint:-21200:ISM780:14400019:000:1396 Nf-From: ISM780!bruce Nov 20 22:23:00 1984 > Bill Shannon says in part: > ... 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"); > } > > ... Where ^D is your EOT character. If the program terminates > when you type ^D then your stdio works properly. ... > > ... 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. I believe your test program doesn't produce the desired results because it's buggy, not stdio. Try the following on a system that doesn't have a buggered fread(), notice the call to feof I've inserted: #include char buf[256]; main() { register int n; while (!feof(stdin) && (n = fread(buf, 1, sizeof buf, stdin))) fwrite(buf, 1, n, stdout); printf("got EOF\n"); } I've tested this on our VAX IS/3 system (System III stdio) and with our vanilla SystemV stdio. Both versions produced the desired (i.e., correct) behaviour. Bruce Adler {sdcrdcf,uscvax,ucla-vax,vortex}!ism780!bruce Interactive Systems decvax!yale-co!ima!bruce