Below is the program for which am expecting the program to go in deadlock because pthread_join() is a blocking wait on a thread(it is waiting to terminate).
But i see that pthread_join() does not block and returns with failure(35)
Can you help me understand, why pthread_join() unblocks? Because main thread is yet to get terminate and probably this should be a deadlock?
#include <pthread.h>
int
main(int argc, char *argv[])
{
void *res;
int s;
printf("Message from main()\n");
s = pthread_join(pthread_self(), &res);
if (s != 0)
printf("pthread_join(): %d",s);
printf("Thread returned %d\n", (int) res);
exit(0);
}
Here is the output:
Message from main()
pthread_join(): 35
Thread returned 134514009
printf("pthread_join(): %d",s);do{errno = s; perror("pthread_join()");}and you might receive enlightning information. - alk