> The term you're looking for here is "atomic".
> In general, you can make no assumptions about any of the stdio calls
> (fwrite, fprintf etc.). If you need this type of control, you should
> use the write() function only. write() calls to a file opened in
> append mode (O_APPEND) are atomic *provided*:
> - the file is not remote via NFS
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This condition is not necessary I believe. The O_APPEND will still work
correctly. It will guarantee that one set of data will appear after the other
set of data, and they won't write over each other. The machine acting as the
file server keeps track of the fact that the operations are O_APPEND and
guarantees the write() will complete before the other write() does some work.
Try writing a program that does an atomic write on an 8mb piece of data over
an NFS mount. That process cannot be killed, not even with a -KILL signal.
Even though the data is sent over the network as several chunks, the server
will not let any other data into that file (assuming all have specified the
O_APPEND flag) until after the write() completes.
GREG