Use pthread_once(3T) to call an initialization routine the first time pthread_once(3T) is called. Subsequent calls to pthread_once() have no effect.
Prototype: int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
#include <pthread.h> pthread_once_t once_control = PTHREAD_ONCE_INIT; int ret; ret = pthread_once(&once_control, init_routine);
The once_control parameter determines whether the associated initialization routine has been called.
pthread_once() returns zero after completing successfully. Any other returned value indicates that an error occurred. When the following condition occurs, pthread_once() fails and returns the corresponding value.