I learned that the POSIX C library guarantees that, when multiple processes are writing to the same file, and all of them have the file opened for appending, data shall not be lost.
I don't think it guarantees that data shall not be lost ... There's still to much going on to guarantee no lost data (you can still get errors such as EFBIG, EINTR, ENOSPC, and EIO).
From the spec a write can be any size:
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.
The only time to worry is if you're writing to a PIPE or FIFO: Write requests of {PIPE_BUF} bytes or less shall not be interleaved with data from other processes doing writes on the same pipe. Writes of greater than {PIPE_BUF} bytes may have data interleaved, on arbitrary boundaries, with writes by other processes, whether or not the O_NONBLOCK flag of the file status flags is set.
In reply to Re: open for append
by derby
in thread open for append
by cmeyer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |