On Wednesday, March 20, 2019 at 12:57:51 AM UTC+1, David Collier-Brown wrote: > > It's a known bad thing to defer a close for anything buffered, as > discussed at https://www.joeshaw.org/dont-defer-close-on-writable-files/ > but some constructs lack a Sync() call. > > Note from the Linux close documentation:
Not checking the return value of close() is a common but nevertheless serious programming error. It is quite possible that errors on a previous write <https://linux.die.net/man/2/write>(2) operation are first reported at the final close(). Not checking the return value when closing the file may lead to silent loss of data. This can especially be observed with NFS and with disk quota. A successful close does not guarantee that the data has been successfully saved to disk, as the kernel defers writes. It is not common for a file system to flush the buffers when the stream is closed. If you need to be sure that the data is physically stored use fsync <https://linux.die.net/man/2/fsync>(2). (It will depend on the disk hardware at this point.) > [...] Manlio Perillo -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.