fork(3) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <pthread.h>
  4. #define SUCCESS 0
  5. using namespace std;
  6.  
  7. int main() {
  8. int res;
  9. pthread_mutex_t t;
  10. pthread_mutex_init(&t, NULL);
  11.  
  12. res = pthread_mutex_lock(&t);
  13.  
  14. res = pthread_mutex_destroy(&t);
  15. if (res != SUCCESS)
  16. {
  17. cout << "Failed to delete: " << strerror(res) << " # " << t.__data.__lock << " " << t.__data.__nusers << endl;
  18. }
  19. else
  20. {
  21. cout << "Deleted!" << endl;
  22. }
  23.  
  24. res = pthread_mutex_unlock(&t);
  25. cout << res << endl;
  26. pthread_exit(NULL);
  27.  
  28. return 0;
  29.  
  30. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Deleted!
0