Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.wizards Subject: Re: EOF problem under 4.3 and 2.10 BSD Keywords: EOF stdio Message-ID: <2697@solo1.cs.vu.nl> Date: 5 Jun 89 18:28:38 GMT References: <2879@cadre.dsl.PITTSBURGH.EDU> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 23 jack@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@cs.vu.nl, mcvax!botter!maart