EOF problem under 4.3 and 2.10 BSD
Maarten Litmaath
maart at cs.vu.nl
Tue Jun 6 04:28:38 AEST 1989
jack at cadre.dsl.PITTSBURGH.EDU (Jack Nelson) writes:
\... If one now hits ^D (EOF) at the prompt, the
\last line (or else just the prompt if there was no input after the
\last prompt) spews out repeatedly until interrupted with ^C.
\ Under sysV, a ^D just reechos the last line, which seems more
\reasonable.
It is indeed! The problem: some BSD developer introduced the `sticky EOF'
concept for stdio - once EOF has been encountered, the flag signaling this
condition won't be reset if more input is available, UNTIL clearerr() has
been called for the corresponding stream.
Note: you didn't test the return value from gets() - it will return (char *) 0
for EOF (or error; use ferror()/feof() to distinguish).
\...
\ for (;;) {
\ printf("> ");
\ gets(line);
\ printf("line is %s\n",line);
\ }
--
"Your password [should be] like your |Maarten Litmaath @ VU Amsterdam:
toothbrush." (Don Alvarez) |maart at cs.vu.nl, mcvax!botter!maart
More information about the Comp.unix.wizards
mailing list