Crash after write in linux
linux
Solution
If you're using `write` (and not `fwrite` or `std::ostream::write`), then there is no in process buffering. If there is no system failure, then the data will, sooner or later (and generally fairly soon) be written to disk.
If you're really concerned by data integrity, you can or in the flags `O_DSYNC` and `O_SYNC` to the flags when you open the file. If you do this, you are guaranteed that the data is physically written to the disk before the return from `write`.
Problem
What would happen if I were to use write() to write some data to a file on disk. But my application were to crash before flushing. Is it guaranteed that my data will get eventually flushed to disk if there is no system failure?