Sometimes, we might have a situation wherein we want to check whether a particular thread is still alive or not; one way to do so is via the pthread_tryjoin_np(3) API:
#define _GNU_SOURCE /* See feature_test_macros(7) */#include <pthread.h>int pthread_tryjoin_np(pthread_t thread, void **retval);int pthread_timedjoin_np(pthread_t thread, void **retval, const struct timespec *abstime);
The first parameter to pthread_tryjoin_np(3) is the thread we are attempting to join to; (the second parameter, as usual, is the target thread's termination status). Notice the try phrase within the API – this typically specifies that the call is non-blocking; in other words, we perform a non-blocking join on the target thread. If ...