pthread_join(3) — Subroutines
Digital
NAME
pthread_join − Causes the calling thread to wait for the termination of a specified thread.
SYNOPSIS
#include <pthread.h>
int pthread_join(
pthread_t thread ,
pthread_addr_t ∗status );
PARAMETERS
threadThread whose termination is awaited by the caller of this routine.
statusStatus value of the terminating thread when that thread calls pthread_exit.
DESCRIPTION
This routine causes the calling thread to wait for the termination of a specified thread. A call to this routine returns after the specified thread has terminated.
Any number of threads can call this routine. All threads are awakened when the specified thread terminates.
If the current thread calls this routine, a deadlock results.
The results of this routine are unpredictable if the value for thread refers to a thread object that no longer exists.
RETURN VALUES
If an error condition occurs, this routine returns −1 and sets errno to the corresponding error value. Possible return values are as follows:
| Return | Error | Description |
| 0 | Successful completion. | |
| −1 | [EINVAL] | The value specified by thread is invalid. |
| −1 | [ESRCH] | The value specified by thread does not refer to a currently existing thread. |
| −1 | [EDEADLK] | A deadlock is detected. |