what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ......

but is there a sharp difference between those 2 instruction .....

thank you

this is my 3rd question today forgive me :smiley:

O_APPEND guarantees that every write to the file will be at the end of the file. lseek guarantees that the file pointer is positioned to the current EOF of the file. It does not guarantee that subsequent writes will be at the end of the file.

The above is something that you only worry about when multiple processes or threads are writing to one file.

Neither guarantees any kind of sequence of I/O writes when there are multiple writers. If you need that, then you have to resort to something like SYSV semaphores for multi-process apps or mutxes in the case of multi-threaded apps.

1 Like