PTHREAD_JOIN(3P) BSD PTHREAD_JOIN(3P)
NAME
pthread_join - Waits for a thread to terminate
SYNOPSIS
#include <pthread.h>
int pthread_join (thread, status)
pthread_t thread;
void *status;
DESCRIPTION
The pthread_join function blocks execution of the calling thread until
the target thread, specified by the thread argument, terminates. If the
target thread has already terminated, pthread_join returns without
blocking.
The arguments specify the following:
thread
Specifies the ID of the thread to wait for.
status
Specifies the location in which the exit status of the joined thread
will be stored.
When the target thread exits, the exit status of the thread is stored in
the status argument unless status is a null pointer.
A thread may be joined by many threads until it is detached.
NOTES
This interface is based on draft 4 of the IEEE P1003.4a standard, and
will be changed to conform to the final version.
DIAGNOSTICS
Upon successful completion, a value of 0 (zero) is returned. Otherwise,
-1 is returned and errno is set to indicate the error.
ERRORS
If the pthread_join function fails, errno may be set to one of the
following values:
[EINVAL] The value specified by the thread argument is invalid.
[ESRCH] The value specified by the thread argument does not refer to an
existing thread.
[EDEADLK] A deadlock condition was detected: the target thread is the
calling thread.
SEE ALSO
pthread_create(3P), wait(2)