---
name: "pthread_exit"
section: "3thr"
platform: "linux"
package: "glibc-doc"
version: "2.1.3-20"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/pthread_exit/3thr"
---

# pthread\_exit(3thr)

terminate the calling thread

## NAME

pthread\_exit - terminate the calling thread

## SYNOPSIS

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

**void pthread\_exit(void \****retval***);**

## DESCRIPTION

**pthread\_exit** terminates the execution of the calling thread. All cleanup handlers that have been set for the calling thread with [**pthread\_cleanup\_push**(3)](/pthread_cleanup_push/3.md) are executed in reverse order (the most recently pushed handler is executed first). Finalization functions for thread-specific data are then called for all keys that have non- **NULL** values associated with them in the calling thread (see [**pthread\_key\_create**(3)](/pthread_key_create/3.md)). Finally, execution of the calling thread is stopped.

The  *retval* argument is the return value of the thread. It can be consulted from another thread using  [**pthread\_join**(3)](/pthread_join/3.md).

## RETURN VALUE

The  **pthread\_exit** function never returns.

## AUTHOR

Xavier Leroy \<Xavier.Leroy@inria.fr\>

## SEE ALSO

[**pthread\_create**(3)](/pthread_create/3.md), [**pthread\_join**(3)](/pthread_join/3.md).
