pthread_cleanup_push(3P)			      pthread_cleanup_push(3P)
      pthread_cleanup_push, pthread_cleanup_pop - manage	thread cleanup
     handlers
     #include <pthread.h>
     void pthread_cleanup_push(void (*cleanup)(void *),	void *arg);
     void pthread_cleanup_pop(int exec);
     A thread may register cleanup handlers which are automatically called on
     behalf of the thread when it terminates either through cancellation [see
     pthread_cancel()],	explicitly exiting [see	pthread_exit()]	or by
     returning from its	start function [see pthread_create()].	Handlers are
     run in order: most	recently registered first.
     Handlers have strict scoping rules: the push and pop must be in the same
     C lexical scope; that is, the pop operation must match the	push operation
     in	the same C statement block.  Threads should never jump out of or into
     a cleanup pair, for example using goto or longjmp().
     The pthread_cleanup_push()	function registers the function	cleanup	as a
     cleanup handler for the calling thread.  When invoked, cleanup will be
     passed the	parameter arg.
     The pthread_cleanup_pop() function	unregisters the	last handler.  If the
     parameter exec is non-zero	then the handler will be executed.
     Not applicable.
 
     pthread_cancel(3P), pthread_exit(3P), pthread_create(3P), longjmp(3C).
									PPPPaaaaggggeeee 1111 [ Back ]
 |