Talk:Append a record to the end of a text file: Difference between revisions

Content added Content deleted
Line 83: Line 83:


Single <code>write</code> to a file opened with <code>O_APPEND</code> is atomic if the underlying file system supports it. For example, it's not garanteed under NFS, where a lock is necessary (and still not garanteed to work, depending on the bugginess of OS). A <code>printf</code> by default calls flush on end of line if output is tty, otherwise tends to only flush when buffer is full. --[[User:Ledrug|Ledrug]] 22:10, 26 September 2011 (UTC)
Single <code>write</code> to a file opened with <code>O_APPEND</code> is atomic if the underlying file system supports it. For example, it's not garanteed under NFS, where a lock is necessary (and still not garanteed to work, depending on the bugginess of OS). A <code>printf</code> by default calls flush on end of line if output is tty, otherwise tends to only flush when buffer is full. --[[User:Ledrug|Ledrug]] 22:10, 26 September 2011 (UTC)

ThanX and Ouch... [Linux NFS Overview, FAQ and HOWTO Documents http://nfs.sourceforge.net/#faq_a9]
* A9. Why does opening files with O_APPEND on multiple clients cause the files to become corrupted?
* A. The NFS protocol does not support atomic append writes, so append writes are never atomic on NFS for any platform.
Commentary: Makes appending to the end of a file a bit complicated. It would be nice if there was a way of querying a file to see if writes are atomic in its filesystem.

Is it worth continuing with this task as it seems to lead to potentially "hairy/complicated" solutions?

[[User:NevilleDNZ|NevilleDNZ]] 22:50, 26 September 2011 (UTC)