## NAME

pthread_cleanup_pop, pthread_cleanup_push - establish cancellation handlers

## SYNOPSIS

#include <pthread.h>

void pthread_cleanup_pop(int execute);

void pthread_cleanup_push(void (*routine)(void*), void *arg);

## DESCRIPTION

pthread_cleanup_pop() removes the routine at the top of the calling thread's cancellation cleanup stack and optionally invoke it (if execute is non-zero).

pthread_cleanup_push() pushes the specified cancellation cleanup handler routine onto the calling thread's cancellation cleanup stack. The cancellation cleanup handler will be popped from the cancellation cleanup stack and invoked with the argument arg when:

- The thread exits (that is, calls pthread_exit()).

- The thread acts upon a cancellation request.

- The thread calls pthread_cleanup_pop() with a non-zero execute argument.

These functions has been implemented as macros. The application shall ensure that they appear as statements, and in pairs within the same lexical scope (that is, the pthread_cleanup_push() macro may be thought to expand to a token list whose first token is '{' with pthread_cleanup_pop() expanding to a token list whose last token is the corresponding '}' ).

The effect of the use of return, break, continue, and goto to prematurely leave a code block described by a pair of pthread_cleanup_push() and pthread_cleanup_pop() functions calls is undefined.

## RETURN VALUES

None

## ERRORS

None

## SEE ALSO

pthread_cancel(), pthread_setcancelstate()

#### Home page (Kernel)

## < Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2018 >