---
name: "pthread_getspecific"
section: "3"
platform: "macos"
package: "libpthread"
version: "539.100.4"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/pthread_getspecific"
---

# pthread\_getspecific(3)

get a thread-specific data value

## NAME

**pthread\_getspecific** – get a thread-specific data value

## SYNOPSIS

**#include \<pthread.h\>**

*void* *\**\

**pthread\_getspecific**(*pthread\_key\_t key*);

## DESCRIPTION

The **pthread\_getspecific**() function returns the value currently bound to the specified *key* on behalf of the calling thread.

The effect of calling **pthread\_getspecific**() with a *key* value not obtained from **pthread\_key\_create**() or after *key* has been deleted with **pthread\_key\_delete**() is undefined.

The **pthread\_getspecific**() function may be called from a thread-specific data destructor function.

## RETURN VALUES

The **pthread\_getspecific**() function will return the thread-specific data value associated with the given *key*. If no thread-specific data value is associated with *key*, then the value NULL is returned.

## ERRORS

None.

## SEE ALSO

[pthread\_key\_create(3)](/pthread_key_create/3.md), [pthread\_key\_delete(3)](/pthread_key_delete/3.md), [pthread\_setspecific(3)](/pthread_setspecific/3.md)

## STANDARDS

The **pthread\_getspecific**() function conforms to ISO/IEC 9945-1:1996 (“POSIX.1”).
