PTHREAD_ONCE(3P) SysV PTHREAD_ONCE(3P)
NAME
pthread_once - Calls an initialization routine Threads Library
(libpthreads.a)
SYNOPSIS
#include <pthread.h>
static pthread_once_t once_block= pthread_once_init;
int pthread_once (once_block, init_routine)
pthread_once_t *once_block;
void(*init_routine)();
DESCRIPTION
The pthread_once function determines whether or not init_routine has been
called by a previous pthread_once call; if init_routine has not been
called, pthread_once calls it.
The pthread_once function does not return to any calling thread until the
init_routine has been completed. You should declare a single once_block
for each initialization routine.
The arguments specify the following names:
once_block
Specifies a name to use for the routine that is used to check
whether the initialization routine has already been executed.
init_routine
Specifies the name of the initialization routine.
Undefined behavior results if once_block is not initialized or is not
declared as static.
NOTES
This interface is based on draft 4 of the IEEE P1003.4a standard, and
will be changed to conform to the final version.
DIAGNOSTICS
Upon successful completion, a value of 0 (zero) is returned. Otherwise,
-1 is returned and errno is set to indicate the error.
ERRORS
If the pthread_once function fails, errno may be set to one of the
following values:
[EINVAL] The value specified by the once_block or init_routine argument
is invalid.
SEE ALSO
pthread_mutex_init(3P), pthread_cond_init(3P)