in reply to Re^5: Writing to a log file without colliding
in thread Writing to a log file without colliding
open is still a separate step. Another process may have appended data to the file between your opening it and appending to it. Your file pointer will not advance to reflect the new end of the file, so you will overwrite that processes' data.From the Solaris write(2) manpage:
If the O_APPEND flag of the file status flags is set, the file offset will be set to the end of the file prior to each write and no intervening file modification operation will occur between changing the file offset and the write operation.This is for example how multiple apache processes all manage to append to the same log file without explicit locking.
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Writing to a log file without colliding
by Aristotle (Chancellor) on Aug 17, 2004 at 15:06 UTC |