thr_join

Waits for a thread to terminate.

Library:LibC
Classification:UNIX International
Service:Threads

Syntax

  #include <thread.h>
   
  int thr_join (
     thread_t    wait_for,
     thread_t   *dead,
     void      **status);
  

Parameters

wait_for

(IN) Specifies the thread to wait for. To join the next available thread, set it to 0.

dead

(OUT) Points to the location of the ID of the thread that was terminated. This parameter can be NULL.

status

(OUT) Points to the location where the application-defined status of the terminated thread is returned. This parameter can be NULL.

Return Values

If successful, returns 0. Otherwise, returns one of the following error codes:

Decimal

Constant

Description

15

EDEADLK

A deadlock was detected or the thread parameter specifies the calling thread.

77

ERSCH

No joinable thread was found that corresponded to the thread ID.

Remarks

Only joinable application threads can be joined by calling thr_join. When a joinable thread exits and a thread is not already waiting to join the exiting thread, the system maintains sufficient state to support subsequent calls to thr_join. If you do not call thr_join on an exited joinable thread, system resources are held up unnecessarily.

See Also