1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2008-12-04 "Linux" "Linux Programmer's Manual"
28 pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop
29 thread cancellation clean-up handlers while saving cancelability type
32 .B #include <pthread.h>
34 .BI "void pthread_cleanup_push_defer_np(void (*" routine ")(void *),"
36 .BI "void pthread_cleanup_pop_restore_np(int " execute );
39 Compile and link with \fI\-pthread\fP.
41 These functions are the same as
42 .BR pthread_cleanup_push (3)
44 .BR pthread_cleanup_pop (3),
45 except for the differences noted on this page.
48 .BR pthread_cleanup_push (3),
49 .BR pthread_cleanup_push_defer_np ()
52 onto the thread's stack of cancellation clean-up handlers.
53 In addition, it also saves the thread's current cancelability type,
54 and sets the cancelability type to "deferred" (see
55 .BR pthread_setcanceltype (3));
56 this ensures that cancellation clean-up will occur
57 even if the thread's cancelability type was "asynchronous"
61 .BR pthread_cleanup_pop (3),
62 .BR pthread_cleanup_pop_restore_np ()
63 pops the top-most clean-up handler from the thread's
64 stack of cancellation clean-up handlers.
65 In addition, it restores the thread's cancelability
66 type to its value at the time of the matching
67 .BR pthread_cleanup_push_defer_np ().
69 The caller must ensure that calls to these
70 functions are paired within the same function,
71 and at the same lexical nesting level.
72 Other restrictions apply, as described in
73 .BR pthread_cleanup_push (3).
75 This sequence of calls:
79 pthread_cleanup_push_defer_np(routine, arg);
80 pthread_cleanup_pop_restore_np(execute);
84 is equivalent to (but shorter and more efficient than):
86 .\" As far as I can see, LinuxThreads reverses the two substeps
87 .\" in the push and pop below.
92 pthread_cleanup_push(routine, arg);
93 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
95 pthread_setcanceltype(oldtype, NULL);
96 pthread_cleanup_pop(execute);
100 .\" Available since glibc 2.0
102 These functions are nonstandard GNU extensions;
103 hence the suffix "_np" (nonportable) in the names.
105 .BR pthread_cancel (3),
106 .BR pthread_cleanup_push (3),
107 .BR pthread_setcancelstate (3),
108 .BR pthread_testcancel (3),
111 This page is part of release 3.67 of the Linux
114 A description of the project,
115 information about reporting bugs,
116 and the latest version of this page,
118 \%http://www.kernel.org/doc/man\-pages/.