Multiple file descriptors to the same file, C Multiple file descriptors to the same file, C multithreading multithreading

Multiple file descriptors to the same file, C


For Linux systems you don't need multiple file descriptors to do this. You can share a single file descriptor and use pread to atomically do a seek / read operation without modifying the file descriptor at all.


That's ok. You can open all times you want the same file and each file descriptor will be independent from each other.


That should work fine, provided each thread has its own file handle. Since you mention use of fclose(), that suggests you are also using fopen() in each thread and each thread only affects its own FILE * variable.

Is there a problem?