title: Is file append atomic in UNIX?
body: <p>In general, what can we take for granted when we append to a file in UNIX from multiple processes?  Is it possible to lose data (one process overwriting the other's changes)?  Is it possible for data to get mangled?  (For example, each process is appending one line per append to a log file, is it possible that two lines get mangled?)  If the append is not atomic in the above sense, then what's the best way of ensuring mutual exclusion?</p>