Till recently I was under the impression that the flag O_APPEND is
used for opeing a file so that the file pointer will be at the end of
the file.
But it looks like it s actually a property of the the succeeding
write() s, whereby whenever a write() is done of teh file descriptor,
*atomically* the file pointer will be moved to the end of the file and
the data appended. ( Not only is the seeking and writing atomic, but
also will be will be done in an exclusively "locked" fashion, so that
any other process writing to the same file, opened with O_APPEND, will
not write over one another's data )
This seems to be true even if some totally unrelated process has the
file opened for writing.
Sonsider the following sequence of events, in a multi processor
machine.
1.process A opened teh file O_APPEND
2. Process B also opens with O_APPEND
3. Process A write() s
4. Process B also write() s
Process B s data will be appended after that of process A.
If this is true ( somebody correct me if I m wrong ), I m sure there
are many people out there who shared this misconcept with me ( that
O_APPEND is just to open a file so that the file pointer will be at
the end of it after opening ).
--sony