Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

pthread_cleanup_pop(2) OSS System Calls Reference Manual
NAME
pthread_cleanup_pop - (Macro) Removes the cleanup-handler routine from the calling thread’s
cleanup-handler stack and optionally executes it
LIBRARY
None. This application program interface is implemented as a macro.
SYNOPSIS
#include <pthread.h> | #include <spthread.h>
/* pthread.h is required to use POSIX User Thread Model library */
/* spthread.h is required to use Standard POSIX Threads library */
void pthread_cleanup_pop(
int execute);
PARAMETERS
execute Controls whether the cleanup-handler routine specified in the matching call to
pthread_cleanup_push( ) is executed. If execute is nonzero, the cleanup-
handler routine executes.
DESCRIPTION
This macro removes the cleanup-handler routine established by the matching call to
pthread_cleanup_push( ) from the calling thread’s cleanup-handler stack, then executes it if the
value of execute is nonzero.
A cleanup-handler routine can be used to clean up from a block of code whether the code is
exited by normal completion, cancelation, or the raising (or reraising) of an exception. The rou-
tine is popped from the calling thread’s cleanup-handler stack and is executed with its arg
parameter when any of the following actions occur:
The thread calls pthread_cleanup_pop( ) and specifies a nonzero value for the execute
parameter.
The thread calls pthread_exit().
The thread is canceled.
An exception is raised and is caught when the system unwinds the calling thread’s stack
to the lexical scope of the pthread_cleanup_push( ) and pthread_cleanup_pop() mac-
ros.
This macro and pthread_cleanup_push() must appear in pairs within the same lexical scope.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
To use this macro in a threaded application that uses the POSIX User Thread Model library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks:
Include the pthread.h header file in the application.
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
To use this macro in a threaded application that uses the Standard POSIX Threads library on sys-
tems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the follow-
ing tasks:
576 Hewlett-Packard Company 527186-023