concurrent access to file linux

It's your responsibility in a multithreaded application to serialize access to file descriptors. Across processes you can use the flock(2) syscall to synchronize access to the same file.

The kernel won't crash if you access the same file from two different processes/threads, but it may overwrite or corrupt the file position and file data in an undefined way.


Linux doesn't use any locking mechanism to protect multithread writing to a file.

You have to use your own mutex to protect your file.