NAME
mthr_join - wait for another thread's termination

SYNOPSIS
#include <mthread.h>

mthread_p mthr_join(mthread_p tp, int *exitloc);

DESCRIPTION
mthr_join() waits until the thread specified by tp terminates. tp must be a valid thread handle obtained by a call to mthr_create(3) or mthr_self(3).

If exitloc is not a null pointer, the exitvalue of the terminated thread will be stored at this location.

Only nondetached threads could be joined. Detached threads are destroyed when calling mthr_exit(3) whereas non detached threads are converted to zombie threads. mthr_join() frees this zombies and returns thier exitvalue. Moreover only one thread could successfully join a thread. All other calls with the same value for tp will return prematurely.

As it's senseless for a thread to wait for its own termination, calls to mthr_join() with tp equal to the calling thread's handle are not allowed.

RETURN VALUES
After successfully joining the requested thread, its thread handle is returned. Otherwise a null handle is returned and merrno is set to indicate the error.

ERRORS
mthr_join() fails if one or more of the following is true:

SEE ALSO
mthreads(3), mthr_create, mthr_self(3), mthr_exit(3)