Program design which ensures file integrity even when terminated forcibly when writing to the file?

41 views Asked by At

As we know, unfinished/forcibly interrupted fflush calls in C may leave a file corrupted and unusable. It would be nice if data integrity is unaffected (i.e. the file remains valid, despite some data loss) when forcible termination of the program occurs (also when the power is suddenly lost).

The simplest approach is to create a backup file; there must exists some other methods. So:

  1. What program designs can be used to prevent such corruption?
  2. Is using two or more files the only way?
  3. What sorts of such protections does a database engine implement?

There are plenty of information online about how a filesystem implement such protections, but I am asking about a single program and a few files instead of the entire filesystem, so it is harder to search for an answer.

0

There are 0 answers