Protect against non-atomic file operations
Writing a file (ex: a syncdb or package file) is a non-atomic file operation. Depending on the underlying filesystem, a unexpected shutdown could result in a partly written file, which could be problematic.
To avoid this, fsync(2) can be used, before moving the file in place (rename(2)).
Related: #105 (closed).
Edited by Kristian Klausen