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

pthread_cleanup_push(2) OSS System Calls Reference Manual
NAME
pthread_cleanup_push - (Macro) Establishes a cleanup-handler routine to be executed when the
thread terminates
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_push(
void (*routine) (void *),
void *arg);
PARAMETERS
routine Specifies the routine to be executed as the cleanup handler.
arg Specifies an argument to be passed to the cleanup routine.
DESCRIPTION
This macro pushes the specified routine onto the calling thread’s cleanup- handler stack. The
cleanup-handler routine is popped from the stack and executed with the value specified by the
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() pair.
This routine and pthread_cleanup_pop() 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:
Include the spthread.h header file in the application.
Compile the application using the _SPT_MODEL_ feature test macro or equivalent
compiler command option.
578 Hewlett-Packard Company 527186-023