[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_cleanup_push

Establishes a cleanup handler to be executed when the thread exits or is canceled.

Syntax

pthread_cleanup_push(
                     *routine,
                     arg );
 


Argument Data Type Access

routine opaque pthread_ read cleanup_t arg opaque pthread_addr_t read


C Binding

int
pthread_cleanup_push(
pthread_cleanup_t *routine,
pthread_addr_t arg);

Arguments

routine
Routine executed as the cleanup handler.
arg
Argument executed with the cleanup routine.

Description

This routine pushes the specified routine onto the calling thread's cleanup stack. The cleanup routine is popped from the stack and executed with the arg argument when any of the following actions occur:

This routine and pthread_cleanup_pop are implemented as macros and must appear as statements and in pairs within the same lexical scope. You can think of the pthread_cleanup_push macro as expanding to a string whose first character is a left brace ({) and pthread_ cleanup_pop as expanding to a string containing the corresponding right brace (}).

Return Values

If an error is detected, it may be indicated by sending the thread a synchronously generated signal.



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]