hi, I'm using fcntl for file locking but if say I want to lock just the end of the file for appending, what values do I put into the flock structure?
I know that for l_whence I can set it to SEEK_END but what about l_start and l_len?
If you want to guarantee appending from different threads/processes you need to open it as ios_base::app. That guarantee's correct appending in all cases as the append is done as an atomic operation in the file system.
Q1) @kbw, the link you gave didn't say that appending using ios::app is atomic...
Q2) Nonetheless, how do I go about programmatically locking the end of file?
Q3) what about reading from a file? I do need to lock it with fcntl or lockf when I'm reading right?