Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- int check_thread_joinable(pthread_t thread) {
- pthread_attr_t attr;
- int detachstate;
- int result;
- // Get thread attributes
- result = pthread_getattr_np(thread, &attr);
- if (result != 0) {
- return -1; // Error getting attributes
- }
- // Get detach state
- result = pthread_attr_getdetachstate(&attr, &detachstate);
- if (result != 0) {
- pthread_attr_destroy(&attr);
- return -1; // Error getting detach state
- }
- // Clean up
- pthread_attr_destroy(&attr);
- // Return whether thread is joinable
- return (detachstate == PTHREAD_CREATE_JOINABLE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement