20. Thread Cancellation Manager — RTEMS POSIX API Guide 5.4-rc2 (21st August 2026) documentation

# 20. Thread Cancellation Manager

## 20.1. Introduction

The thread cancellation manager is …

The directives provided by the thread cancellation manager are:

- pthread_cancel - Cancel Execution of a Thread

- pthread_setcancelstate - Set Cancelability State

- pthread_setcanceltype - Set Cancelability Type

- pthread_testcancel - Create Cancellation Point

- pthread_cleanup_push - Establish Cancellation Handler

- pthread_cleanup_pop - Remove Cancellation Handler

## 20.2. Background

There is currently no text in this section.

## 20.3. Operations

There is currently no text in this section.

## 20.4. Directives

This section details the thread cancellation manager’s directives. A subsection is dedicated to each of this manager’s directives and describes the calling sequence, related constants, usage, and status codes.

### 20.4.1. pthread_cancel - Cancel Execution of a Thread

CALLING SEQUENCE:

    #include <pthread.h>
    int pthread_cancel(
        pthread_t thread
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES:

### 20.4.2. pthread_setcancelstate - Set Cancelability State

CALLING SEQUENCE:

    #include <pthread.h>
    int pthread_setcancelstate(
        int state,
        int *oldstate
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES:

### 20.4.3. pthread_setcanceltype - Set Cancelability Type

CALLING SEQUENCE:

    #include <pthread.h>
    int pthread_setcanceltype(
        int type,
        int *oldtype
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES:

### 20.4.4. pthread_testcancel - Create Cancellation Point

CALLING SEQUENCE:

    #include <pthread.h>
    void pthread_testcancel(
        void
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES:

### 20.4.5. pthread_cleanup_push - Establish Cancellation Handler

CALLING SEQUENCE:

    #include <pthread.h>
    void pthread_cleanup_push(
        void (*routine)(void*),
        void *arg
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES:

### 20.4.6. pthread_cleanup_pop - Remove Cancellation Handler

CALLING SEQUENCE:

    #include <pthread.h>
    void pthread_cleanup_pop(
        int execute
    );

STATUS CODES:

`E` | The

DESCRIPTION:

NOTES: