pthread_cleanup_push(3T) DG/UX R4.11MU05 pthread_cleanup_push(3T)
NAME
pthread_cleanup_push, pthread_cleanup_pop - establish cleanup
handlers
SYNOPSIS
#include <pthread.h>
void pthread_cleanup_push(void (*routine)(void *arg), void *arg);
void pthread_cleanup_pop(int execute);
where:
routine A pointer to a cleanup routine
arg An argument to be passed to the cleanup routine, if it is
executed
execute An integer (0 = do not run routine, nonzero = run it)
DESCRIPTION
The pthread_cleanup_push() function pushes the specified routine onto
the calling thread's cleanup stack. The cleanup routine is popped
from the stack and executed with the argument arg when:
(a) the thread exits, that is, calls pthread_exit() or returns
from its start routine
(b) the thread acts upon a cancellation request, or
(c) the thread calls pthread_cleanup_pop() with a nonzero execute
argument.
The pthread_cleanup_pop() function removes the routine at the top of
the calling thread's cleanup stack and optionally executes it (if
execute is nonzero).
In C, these functions can be (and are) implemented as macros and
shall appear as statements in pairs within the same lexical scope.
That is, the pthread_cleanup_push() macro is expanded to a string
whose first character is { with pthread_cleanup_pop() expanding to a
string whose last character is the corresponding }.
When a process terminates by an explicit call to exit(2) or by other
means, no cancellation handlers or destructor functions are invoked.
The effect of calling longjmp(3C) or siglongjmp(3C) 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(3C) or
siglongjmp(3C) from inside a cleanup routine is also undefined unless
the jump buffer was also filled in the cleanup routine.
DIAGNOSTICS
Return Value
The pthread_cleanup_push() and pthread_cleanup_pop() functions shall
be used as statements. They do not return anything.
Errors
These functions never return errors. Failure to place these
functions in the same lexical scope will likely result in a compile-
time error.
SEE ALSO
pthread_cancel(3T), pthread_setintr(3T). pthread_setintrtype(3T),
pthread_exit(3T), threads(5).
Licensed material--property of copyright holder(s)