Joining Threads (The GNU C Library)

#### 36.2.9.4 Wait for a thread to terminate ¶

The GNU C Library provides several extensions to the `pthread_join` function.

Function: `int` pthread_tryjoin_np `(pthread_t *thread, void **thread_return)` ¶

  Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | See POSIX Safety Concepts.

  Behaves like `pthread_join` except that it will return `EBUSY` immediately if the thread specified by thread has not yet terminated.

Function: `int` pthread_timedjoin_np `(pthread_t *thread, void **thread_return, const struct timespec *abstime)` ¶

  Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | See POSIX Safety Concepts.

  Behaves like `pthread_tryjoin_np` except that it will block until the absolute time abstime measured against `CLOCK_REALTIME` is reached if the thread has not terminated by that time and return `EBUSY`. If abstime is equal to `NULL` then the function will wait forever in the same way as `pthread_join`.

Function: `int` pthread_clockjoin_np `(pthread_t *thread, void **thread_return, clockid_t clockid, const struct timespec *abstime)` ¶

  Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | See POSIX Safety Concepts.

  Behaves like `pthread_timedjoin_np` except that the absolute time in abstime is measured against the clock specified by clockid. Currently, clockid must be either `CLOCK_MONOTONIC` or `CLOCK_REALTIME`.

The `sem_clockwait` function also works using a `clockid_t` argument. See POSIX Semaphores.