thr_join(3T)
NAME
thr_join − wait for thread termination
SYNOPSIS
#include <thread.h>
int thr_join(thread_t wait_for, thread_t ∗departed, void ∗∗status);
MT-LEVEL
MT-Safe
DESCRIPTION
thr_join() blocks the calling thread until the thread specified by wait_for terminates. The specified thread must be in the current process and must not be detached (see thr_create(3T)). If wait_for is (thread_t)0, then thr_join() waits for any undetached thread in the process to terminate.
If departed is not NULL, it points to a location that is set to the ID of the terminated thread if thr_join() returns successfully. If status is not NULL, it points to a location that is set to the exit status of the terminated thread if thr_join() returns successfully.
Multiple threads cannot wait for the same thread to terminate; one thread will return successfully and the others will fail.
RETURN VALUES
Zero is returned when successful. A non-zero value indicates an error.
ERRORS
If any of the following conditions are detected, thr_join() fails and returns the corresponding value:
ESRCH wait_for is not a valid, undetached thread in the current process.
EDEADLK wait_for specifies the calling thread.
SEE ALSO
SunOS 5.2 — Last change: 22 Jan 1993