Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!gatech!mcnc!rti!trt From: trt@rti.UUCP (Thomas Truscott) Newsgroups: comp.os.minix Subject: Re: Minix stdio - 2 of 7 Summary: In _cleanup(), change "fclose" to "fflush" Keywords: stdio Message-ID: <3169@rti.UUCP> Date: 6 Sep 89 18:15:02 GMT References: <1494@bruce.OZ> Organization: Research Triangle Institute, RTP, NC Lines: 37 From postnews Wed Sep 6 14:07:22 1989 > X * Cleanly close and flush all output buffers. This ensures that > X * all streams are written out and closed. ... > X for (i = 0; i < _NFILE; i++) > X if (_iop[i] != NULL) > X (void) fclose(_iop[i]); The last line above should instead be: > X (void) fflush(_iop[i]); The fclose() is an inefficiency dating back to the original stdio. Unless MINIX is strangely different from standard UN*X there is no need to *close* any files, one simply needs to ensure that all streams are written out. If you have a system that can trace system calls, it becomes painfully evident that virtually every command ends with: close(0); close(1); close(2); exit(0); There is no reason whatsoever for the close() calls! Further evidence: * I have changed the fclose to be fflush in various UN*X flavors, the first time was in 1980. Never a glitch. * I have posted flames such as this one (including to this very newsgroup a couple years ago), never a counterargument. I admit this is a minor inefficiency, and I should not be preoccupied with it, but the fix is so trivial that it is very frustrating that no one has bothered to apply it. HELP ME! Tom Truscott