Mail Archives: djgpp/1999/06/16/07:49:15
On Wed, 16 Jun 1999, Andrew R. Gillett wrote:
> In comp.os.msdos.djgpp, Pavlos wrote:
> > >is there any way I can make it so that it creates the
> > >file as soon as I call fopen, and writes to the file as soon as I call
> > >fprintf?
> >
> > Maybe fflush() can help you
>
> Didn't make any difference.
Try "fsync(fileno(f));", where f is the FILE object for the log file.
The call to `fsync' should be IN ADDITION to `fflush', not *instead*
of it.
If that doesn't work, you can call `sync' at strategic places. This
will cause the disk cache to flush all its buffers to the disk, but it
will also slow down your program tremendously, so it is probably
impractical to plug it after every fflush.
If `sync' doesn't help either, then your program is crashing so
quickly and violently that the disk caching is not what prevents the
data from being written to disk.
- Raw text -