Reputation: 9925
I have a loop of write(2) with arbitrary amount of data + EOL and an fsync(2) appending to a file line by line.
Can a crash of the process leave me with a file that has half of the data from the write(2) call written to file? My theory is that if the OS calls fsync occasionally, there might be a coincidence of it happening during a call the write(2) leaving the file with half of the line written, without the ending new line.
Upvotes: 1
Views: 84
Reputation: 126203
Yes. Even without a crash, you might have a partial line written as the write
call might not write all the data passed to it -- it might return a short write.
Upvotes: 1