POSIX requires FILE access to be thread safe, but since fclose closes the file and invalidates the pointer, there is no way (that is, it is not only a specification issue, but also a basic API problem that can never be “fixed” or done for deletion ) to use fclose when another thread can access FILE . You will need to make your own lock.
R .. source share