This is done by specifying one ormore functions that will be called automatically by the pthreads library whenthe thread exits, either due to its own will (e.g. calling pthread_exit()), ordue to it being canceled. When the thread terminates, its cleanup functions arecalled in the reverse order of their registration. So the the last one to beregistered is the first one to be called.
API |
|
pthread_cleanup_push | add a cleanup function to the set of cleanup functions for the current thread. |
pthread_cleanup_pop | removes the last function added with pthread_cleanup_push(). |
|
|
|
|