libuuid's get_clock() function uses GCC's built-in __thread modifier to declare a thread-local static variable containing an fd, and another containing a FILE*. Unfortunately AFAIK there's no support for a destructor call when a thread dies. As a result a program using libuuid and referring to the clock will leak one FD per thread and so eventually die.
1. Use pthreads' TLS implementation, which supports a destructor callback.
2. Push the requirement to the user: store this FD per user-created context and require that they see to destroying contexts.
2a. Do that somewhat half-assedly: support a thread-death callback that will clean up thread-local storage and require that user threads that have touched libuuid should make that callback.
3. Open it once, since you're already using file-locking to mostly-serialise operations on the file.