pthread_cleanup_push(3pthread)


pthread_cleanup_pop, pthread_cleanup_push -- establish cancellation handlers

Synopsis

   cc [options] -Kthread file
   

#include <pthread.h>

void pthread_cleanup_push(void (*routine)(void*), void *arg); void pthread_cleanup_pop(int execute);

Description

pthread_cleanup_push pushes the specified cancellation cleanup handler routine onto the calling thread's cancellation cleanup stack. The cancellation cleanup handler is popped from the cancellation cleanup stack and invoked with the argument arg when: (a) the thread exits (that is, calls pthread_exit), (b) the thread acts upon a cancellation request, or (c) the thread calls pthread_cleanup_pop with a non-zero execute argument.

pthread_cleanup_pop removes the routine at the top of the calling thread's cancellation cleanup stack and optionally invokes it (if execute is non-zero).

These functions may be implemented as macros and will appear as statements and in pairs within the same lexical scope (that is, the pthread_cleanup_push macro may be thought to expand to a token list whose first token is `{' with pthread_cleanup_pop expanding to a token list whose last token is the corresponding `}'.

The effect of calling longjmp or siglongjmp is undefined if there have been any calls to pthread_cleanup_push or pthread_cleanup_pop. The effect of calling longjmp or siglongjmp from inside a cancellation cleanup handler is also undefined.

Return values

pthread_cleanup_pop and pthread_cleanup_push return no value.

Diagnostics

No errors are defined.

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.

References

pthread_cancel(3pthread), pthread_setcancelstate(3pthread), pthread(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004