[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_join

Causes the calling thread to wait for the termination of a specified thread.

Syntax

pthread_join(
             thread,
             status );
 


Argument Data Type Access

thread opaque pthread_t read status opaque pthread_addr_t write


C Binding

int
pthread_join (
pthread_t thread,
pthread_addr_t *status);

Arguments

thread
Thread whose termination is awaited by the caller of this routine.
status
Status value of the terminating thread (in other words, 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.

If the thread exits normally, the status value argument is the address that the specified thread generates as its result. The thread's result is normally returned as the value of the start_ routine argument in its call to pthread_create. If the thread does not exit normally, the value of status is -1.

Any number of threads can call this routine. All calling threads are awakened when the specified thread terminates.

If the current thread calls this routine, a deadlock can result (if it is not detected by the implementation).

The results of this routine are unpredictable if the value for thread refers to a thread object that no longer exists (that is, one that has been detached).

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 an existing thread.



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]