Try changing your original program to call fflush on the stream that you are
writing to after every number is written. This will make sure the
information is flushed to Linux's buffers from the C library's buffers. You
can check the file as it is written. There is a call you can use to stop
buffering entirely, called fsetvbuf (I think; it's something like that,
The numbers probably were in the file until the machine was restarted. The
fsck may have not been able to recover the file. On an off-chance, have a
look in the lost+found directory for the filesystem the file was in. (That
is where files similar to scandisk .CHK files go.)
> -----Original Message-----
> From: Bobby Heffernan [mailto:bobheff at esatclear.ie]
> Sent: 04 February 2000 23:12
> To: Cork LUG
> Subject: [CLUG] files
>>> how and when does linux write it's files to the disk?
> I wrote s imple C program that's doing some caluclations for
> me - every
> time it gets a result it writes the number to a file
> when it's running and you access the file there's nothing there (even
> though I know it has gotten some results)
> the power went and when I restarted the machine the file was empty - I
> had lost about two and a half days of number crunching
> yet - if I set the program to iterate only a few times so that it gets
> one or two results when it finishes (in a few seconds - doing
> about 500
> loops) I look at the file and its got three entries (which is right)
> does linux write the file to the disk only after the program has
> or what??
> Windows NT crashed.
> I am the Blue Screen of Death.
> No one hears your screams.
> Cork maillist - Cork at linux.ie>http://www.linux.ie/mailman/listinfo/cork>
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!