DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_cleanup_push(PTHREAD)


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(PTHREAD), pthread_setcancelstate(PTHREAD), pthread(F)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005