Multithreaded Programming Guide

Return Values

pthread_join() returns zero when it completes successfully. Any other return value indicates that an error occurred. When any of the following conditions are detected, pthread_join() fails and returns the corresponding value.


ESRCH

tid is not a valid, undetached thread in the current process.


EDEADLK

A deadlock would exist, such as a thread waits for itself or thread A waits for thread B and thread B waits for thread A.


EINVAL

The value of tid is invalid.

Remember that pthread_join() works only for target threads that are nondetached. When there is no reason to synchronize with the termination of a particular thread, then that thread should be detached.