in unistd.h
using open() with the O_APPEND flag gives atomic writes always to the end of the file…
this is great and all, but what if i need to know the offset at which it atomically appended to the file…?
i realize O_APPEND is often used for log files, but I’d actually like to know at what offset in the file it atomically appended.
I don’t see any obvious way to do this..? Does anyone know?
Thanks
To get the current position in a file descriptor, use
lseek()with offset0and whenceSEEK_CUR.Note that this will not give you reliable results if the descriptor was opened some other way, i.e. via
socket().