---
name: "pthread_kill_other_threads_np"
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_kill_other_threads_np/3thr"
---

# pthread\_kill\_other\_threads\_np(3thr)

terminate all threads in program except calling thread

## NAME

pthread\_kill\_other\_threads\_np - terminate all threads in program except calling thread

## SYNOPSIS

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

**void pthread\_kill\_other\_threads\_np(void);**

## DESCRIPTION

**pthread\_kill\_other\_threads\_np** is a non-portable LinuxThreads extension. It causes all threads in the program to terminate immediately, except the calling thread which proceeds normally. It is intended to be called just before a thread calls one of the  **exec** functions, e.g.  [**execve**(2)](/execve/2.md).

Termination of the other threads is not performed through [**pthread\_cancel**(3)](/pthread_cancel/3.md) and completely bypasses the cancellation mechanism. Hence, the current settings for cancellation state and cancellation type are ignored, and the cleanup handlers are not executed in the terminated threads.

## AUTHOR

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

## SEE ALSO

[**execve**(2)](/execve/2.md), [**pthread\_setcancelstate**(3)](/pthread_setcancelstate/3.md), [**pthread\_setcanceltype**(3)](/pthread_setcanceltype/3.md), [**pthread\_cancel**(3)](/pthread_cancel/3.md).

## BUGS

According to POSIX 1003.1c, a successful  **exec\*** in one of the threads should terminate automatically all other threads in the program. This behavior is not yet implemented in LinuxThreads. Calling  **pthread\_kill\_other\_threads\_np** before  **exec\*** achieves much of the same behavior, except that if  **exec\*** ultimately fails, then all other threads are already killed.
