News for hackers. Stuff that matters.
Re:Appending to a file from multiple processes by gpderetta on Thursday August 04, 2016 @05:23AM (#12224376)
Posix seems to guarantee that writes with O_APPEND are atomic:

"If the O_APPEND flag of the file status flags is set, the file offset shall be set to the end of the file prior to each write and no intervening file modification operation shall occur between changing the file offset and the write operation."

but then it goes on and says:

"This volume of IEEE Std 1003.1-2001 does not specify behavior of concurrent writes to a file from multiple processes. Applications should use some form of concurrency control."

Also, it does seems to allow a signal to interrupt file I/O.

Anyways, it seems that historical unix behaviour is that signals never interrupt file I/O and O_APPEND can be used for atomic appends. Of course, this is not documented anywhere, but you can find discussions on the topic. In particular, here [1] Linus goes in one of his rants when commenting on a patch to change this behaviour.

[1] http://yarchive.net/comp/linux/wakekill.html

There are no comments on this comment yet.