pthread_cleanup_push(3T) DG/UX 5.4R3.00 pthread_cleanup_push(3T)
NAME
pthreadcleanuppush, pthreadcleanuppop - establish cleanup
handlers
SYNOPSIS
#include <pthread.h>
void pthreadcleanuppush(void (*routine)(void *arg), void *arg);
void pthreadcleanuppop(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 pthreadcleanuppush() 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 pthreadexit() or returns
from its start routine
(b) the thread acts upon a cancellation request, or
(c) the thread calls pthreadcleanuppop() with a nonzero execute
argument.
The pthreadcleanuppop() 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 pthreadcleanuppush() macro is expanded to a string
whose first character is { with pthreadcleanuppop() 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 pthreadcleanuppush() or
pthreadcleanuppop() 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 pthreadcleanuppush() and pthreadcleanuppop() functions shall
be used as statements. They do not return anything.
Errors
These functions never return errors. Failure to place these
Licensed material--property of copyright holder(s) 1
pthread_cleanup_push(3T) DG/UX 5.4R3.00 pthread_cleanup_push(3T)
functions in the same lexical scope will likely result in a compile-
time error.
SEE ALSO
pthreadcancel(3T), pthreadsetintr(3T). pthreadsetintrtype(3T),
pthreadexit(3T), threads(5).
Licensed material--property of copyright holder(s) 2