Comment by gpderetta

Comment by gpderetta 2 months ago

0 replies

It seems to me that the reference to NFS is a red herring. If I disconnect a disk after a program has terminated and before the OS has completed write back, the data is lost, no matter what close has returned. This was well known when removable writable media was more common. Still possible with hot pluggable disks.

If you want to make sure that the data is on stable storage you need fsync (and even then there is no guarantee that the disk will not just die or corrupt data).

If you are writing to a generic FS and don't know if what's on the other side is even a file, then it is not your responsibility of guaranteeing persistence. Some higher level component (for example the script invoking your program) will implement the transactional behaviour.

Remember that your program can always be kill-9'd: you can never guarantee that your output to a pipe is consistent.