Waiting for thread termination
One thread can suspend itself to wait for the termination of another thread
where the parameters have the following meaning:
The ID of the thread of interest,
that is, the non-detached thread whose termination the caller will await.
A (thread_t)0 indicates interest in the next non-detached thread to
terminate (or one that has already terminated, but has not been joined),
whatever its ID happens to be.
will deposit the thread ID of the
terminated thread at this address.
will deposit at this address the
value given as an argument by the terminated thread
when it called
That value should be the address
at which the terminated thread left its return value (exit status).
If the thread of interest has already terminated,
will return immediately; otherwise, the calling thread will block.
If there is more than one thread waiting for the termination of
some particular thread:
The thread of interest will be joined to only one of the waiting threads.
The choice is not predictable.
All other waiting threads will return with the ESRCH error code.
If a thread receives a catchable
signal while blocked in
The signal is handled.
function is transparently restarted.
This is analogous to the
``autorestart option'' for blocking system calls.
(See the description of the SA_RESTART flag
The resources of a non-detached thread
(for example, a stack allocated by the Threads Library)
will not be fully recovered by the Threads Library
until some other thread has called
the terminated thread's exit status.
Beware of lingering zombies! Failing to recover the memory
and resources associated with terminated threads can have
a negative impact on performance.
If the programmer knows at thread creation time that no other thread will
to wait for the new thread,
the THR_DETACHED flag to
should be used.
When a ``detached thread'' terminates, its resources may be recovered
In fact, it is not valid to use
on a detached thread.
By default, new threads are not detached threads.
Termination of the process
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004