PTHREAD_SETSPECIFIC(3P) BSD PTHREAD_SETSPECIFIC(3P)
NAME
pthread_setspecific - Binds a thread-specific value to a key
SYNOPSIS
#include <pthread.h>
int pthread_setspecific (key, value)
pthread_key_t key;
void value;
DESCRIPTION
The pthread_setspecific function binds a thread-specific value with a key
created with a previous call to the pthread_keycreate(3P) argument.
Different threads may bind different values to the same key. The values
are typically pointers to blocks of dynamically allocated memory that
will be used only by the calling thread.
The arguments specify the following:
key Specifies the key that the value argument will be bound to.
value Specifies the value of the thread-specific data to be bound to
the key.
The calling thread must explicitly destroy the old value itself, if
required, before binding the new value using this call.
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_setspecific function fails, errno may be set to the
following value:
[EINVAL] The value specified by the key argument is invalid.
SEE ALSO
pthread_keycreate(3P), pthread_getspecific(3P)