what is the correct behavior of pthread_mutex_destroy when destroying a locked mutex
I wrote the following minimal example: #include <iostream> #include <cstring> #include <pthread.h> #define SUCCESS 0 using namespace std; int main() { int res; pthread_mutex_t t; pthread_mutex_init(&t, NULL); res = pthread_mutex_lock(&t); res = pthread_mutex_destroy(&t); if (res != SUCCESS) { cout << "Failed to delete: " << strerror(res) << " # " << t.__data.__lock << " " << t.__data.__nusers << endl; } else { cout << "Deleted!"<< endl; } res = pthread_mutex_unlock(&t); cout << res << endl; pthread_exit(NULL); return 0; } Also at ideone On one side as someone noted, the standard apparently