- 论坛徽章:
- 4
|
A cancellation clean-up handler is popped from the stack and executed in the following circumstances:
1. When a thread is canceled, all of the stacked clean-up handlers are popped and executed in the reverse of the
order in which they were pushed onto the stack.
2. When a thread terminates by calling pthread_exit(3), all clean-up handlers are executed as described in the
preceding point. (Clean-up handlers are not called if the thread terminates by performing a return from the
thread start function.)
3. When a thread calls pthread_cleanup_pop() with a nonzero execute argument, the top-most clean-up handler is
popped and executed.
POSIX.1 says that the effect of using return, break, continue, or goto to prematurely leave a block bracketed
pthread_cleanup_push() and pthread_cleanup_pop() is undefined. Portable applications should avoid doing this. |
|