Index of Section 2 Manual Pages
| Interix / SUA | pthread_once.2 | Interix / SUA |
pthread_once(2) pthread_once(2)
pthread_once()
NAME
pthread_once() - execute routine only once in a process
SYNOPSIS
#include
int pthread_once(pthread_once_t *once_control, void (*init_routine)
(void));
pthread_once_t once_control = PTHREAD_ONCE_INIT;
DESCRIPTION
The first time it is called by any thread in a process with the
once_control argument set to a specific value, the pthread_once(2)
function executes, without arguments, the subroutine referenced by the
init_routine argument. The once_control argument must be initialized by
the static initializer macro PTHREAD_ONCE_INIT defined in . On
subsequent calls by any thread in the process using the same once_control
value, pthread_once() returns immediately without executing init_routine.
If init_routine is executed, pthread_once() returns only after
init_routine returns.
The pthread_once() function is not a cancellation point. If init_routine
is a cancellation point and is cancelled, the result is the same as though
pthread_once() had never been called.
RETURN VALUES
On success, the function returns 0; otherwise, an error code is returned.
ERRORS
The pthread_once() function can fail for the following reason:
[EINVAL]
The once_control or init_routine argument is invalid.
This function does not return [EINTR].
SEE ALSO
pthread_create(2)
USAGE NOTES
The pthread_once function is thread safe.
The pthread_once function is not async-signal safe.