/* join_self.c Shows that attempting to join with yourself results in a runtime error. man page for pthread_join did no mention needing to include errno.h. */ #include // pthread_t, pthread_create, pthread_join, pthread_self #include // fprintf, stderr #include // EDEADLK void *threadFunc(void *ignore) { int error; if ((error = pthread_join(pthread_self(), NULL)) == EDEADLK) fprintf(stderr, "Joining with your self is not possible\n"); return NULL; } int main() { pthread_t tid; pthread_create(&tid, NULL, threadFunc, NULL); pthread_join(tid, NULL); return 0; }