I know on linux it's possible to count the thread via /proc/self/status or counting the directories in /proc/self/task (at least I think that was the directory), the problem is that involves opening a file descriptor, on modern systems that's not a problem but since the library is supposed to be compatible with older systems as well I have to account for the file descriptor limit which means a possible failure to count the threads via that method, is there any possible way to count the number of threads in the process without opening an fd? Haven't looked into the windows method of doing this but I'd wager CreateToolHelp32Snapshot or whatever it was called can help me out there if need be.

The reason I even thought to attempt this is related to attempting to guarantee mutices are only deleted when no other threads can try to lock it during deletion (since I had to use an allocated pthread_mutex_t to ensure the exposed typedef had a simple initialiser that aligned with window's HANDLE), and the only way I can think of for that is to just refuse to do so while there is more than 1 thread (the main thread) that can potentially try to lock it at the same time the mutex becomes invalid.