[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

pthread_cleanup_pop or pthread_cleanup_push Subroutine

Purpose

Establishes cancellation handlers.

Library

Threads Library (libpthreads.a)

Syntax

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

Description

The pthread_cleanup_push function pushes the specified cancellation cleanup handler routine onto the calling thread's cancellation cleanup stack. The cancellation cleanup handler is popped from the cancellation cleanup stack and invoked with the argument arg when: (a) the thread exits (that is, calls pthread_exit, (b) the thread acts upon a cancellation request, or (c) the thread calls pthread_cleanup_pop with a non-zero execute argument.

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

These functions may be implemented as macros and will 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 calling longjmp or siglongjmp is undefined if there have been any calls to pthread_cleanup_push or pthread_cleanup_pop made without the matching call since the jump buffer was filled. The effect of calling longjmp or siglongjmp from inside a cancellation cleanup handler is also undefined unless the jump buffer was also filled in the cancellation cleanup handler.

Parameters

execute Specifies if the popped routine will be executed.

Implementation Specifics

This subroutine is part of the Base Operating System (BOS) Runtime.

Related Information

The pthread_cancel, pthread_setcancelstate subroutines, the pthread.h file.

Terminating Threads in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

Threads Library Quick Reference in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]