pthread_abort()

Updated: April 19, 2023

Unconditionally terminate the target thread

Synopsis:

#include <pthread.h>

int pthread_abort( pthread_t thread );

Arguments:

thread
The ID of the thread that you want to terminate, which you can get when you call pthread_create() or pthread_self().

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The pthread_abort() function terminates the target thread. Termination takes effect immediately and isn't a function of the cancelability state of the target thread. No cancellation handlers or thread-specific-data destructor functions are executed. Thread abortion doesn't release any application-visible process resources, including, but not limited to, mutexes and file descriptors. Note that the behavior of POSIX calls following a call to pthread_abort() is undefined.

The status of PTHREAD_ABORTED is available to any thread joining with the target thread. The constant PTHREAD_ABORTED expands to a constant expression, of type void *. Its value doesn't match any pointer to an object in memory, or the values NULL and PTHREAD_CANCELED.

The side effects of aborting a thread that's suspended during a call of a POSIX 1003.1 function are the same as the side effects that may be seen in a single-threaded process when a call to a POSIX 1003.1 function is interrupted by a signal and the given function returns EINTR. Any such side effects occur before the thread terminates.

Returns:

EOK
Success.
ESRCH
No thread with the given ID was found.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes