PTHREAD_ONCE(3) BSD Library Functions Manual PTHREAD_ONCE(3)
NAMEpthread_once -- dynamic package initialization
SYNOPSIS#include<pthread.h>
pthread_once_t once_control = PTHREAD_ONCE_INIT;
intpthread_once(pthread_once_t*once_control, void(*init_routine)(void));
DESCRIPTION
The first call to pthread_once() by any thread in a process, with a given once_control, will call the
init_routine() with no arguments. Subsequent calls to pthread_once() with the same once_control will
not call the init_routine(). On return from pthread_once(), it is guaranteed that init_routine() has
completed. The once_control parameter is used to determine whether the associated initialization rou-tine routine
tine has been called.
The function pthread_once() is not a cancellation point. However, if init_routine() is a cancellation
point and is cancelled, the effect on once_controlisasifpthread_once() was never called.
The constant PTHREAD_ONCE_INIT is defined by header <pthread.h>.
The behavior of pthread_once() is undefined if once_control has automatic storage duration or is not
initialized by PTHREAD_ONCE_INIT.
RETURNVALUES
If successful, the pthread_once() function will return zero. Otherwise, an error number will be
returned to indicate the error.
ERRORS
None.
STANDARDSpthread_once() conforms to ISO/IEC 9945-1:1996 (``POSIX.1'').
BSD April 4, 1996 BSD

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors

Report errors in the content of this documentation with the feedback links below.

Bug reports

Report bugs in the functionality of the described tool or API through Bug Reporter.

Formatting problems

Report formatting mistakes in the online version of these pages with the feedback links below.