Newsgroups: comp.os.msdos.djgpp Subject: Re: files not closed after GPF From: richard AT stardate DOT ca (Richard Sanders) X-Newsreader: WinVN 0.99.9 (Released Version) (x86 32bit) References: <20010805030625 DOT 08871 DOT 00002852 AT ng-fr1 DOT aol DOT com> <9kjsnd$ian$1 AT newsg3 DOT svr DOT pol DOT co DOT uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII NNTP-Posting-Host: wlp48.rapidnet.net Message-ID: <3b6dc59f_1@rapidnet.net> Date: 5 Aug 2001 15:15:59 -0700 X-Trace: binaries.vphos.net 997049759 wlp48.rapidnet.net (5 Aug 2001 15:15:59 -0700) Organization: Rapidnet Internet Lines: 24 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <9kjsnd$ian$1 AT newsg3 DOT svr DOT pol DOT co DOT uk>, matt AT the-good-stuff DOT freeserve DOT co DOT uk says... > > >> >> Is it a bug ? > >I think you are doing about as well as can be expected, only losing >one line line that. >crashing with files open can actually wipe your whole file system if >you are exceptionally unlucky. > >If your program was opening the file itself, it could adopt an >"open,append,close quickly" strategy but redirecting the output makes >your shell handle this. > >You could try outputting a few line feeds after critical information >to flush the shell's buffer to disk. Better yet flush the file to disk after every write. If you are using buffered file io (fopen), use fflush( FILE *foo );, for unbuffered io (open) use _dos_commit( int foo );. The flushing will be done before the crash and the info should be in the file, baring other problems.