]>
Commit | Line | Data |
---|---|---|
f06b4f5c MK |
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
4b72fb64 | 4 | .\" %%%LICENSE_START(verbatim) |
f06b4f5c MK |
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. | |
8 | .\" | |
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. | |
13 | .\" | |
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 | |
20 | .\" professionally. | |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
f06b4f5c MK |
25 | .\" |
26 | .TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2008-12-04 "Linux" "Linux Programmer's Manual" | |
27 | .SH NAME | |
28 | pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop | |
29 | thread cancellation clean-up handlers while saving cancelability type | |
30 | .SH SYNOPSIS | |
31 | .nf | |
32 | .B #include <pthread.h> | |
33 | ||
34 | .BI "void pthread_cleanup_push_defer_np(void (*" routine ")(void *)," | |
35 | .BI " void *" arg ); | |
36 | .BI "void pthread_cleanup_pop_restore_np(int " execute ); | |
6030f2d8 | 37 | .fi |
f06b4f5c MK |
38 | .sp |
39 | Compile and link with \fI\-pthread\fP. | |
40 | .SH DESCRIPTION | |
41 | These functions are the same as | |
42 | .BR pthread_cleanup_push (3) | |
43 | and | |
44 | .BR pthread_cleanup_pop (3), | |
45 | except for the differences noted on this page. | |
46 | ||
47 | Like | |
48 | .BR pthread_cleanup_push (3), | |
49 | .BR pthread_cleanup_push_defer_np () | |
50 | pushes | |
51 | .I routine | |
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" | |
b084fc29 | 58 | before the call. |
f06b4f5c MK |
59 | |
60 | Like | |
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 (). | |
68 | ||
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). | |
74 | ||
75 | This sequence of calls: | |
76 | ||
77 | .in +4n | |
78 | .nf | |
79 | pthread_cleanup_push_defer_np(routine, arg); | |
80 | pthread_cleanup_pop_restore_np(execute); | |
81 | .fi | |
82 | .in | |
83 | ||
84 | is equivalent to (but shorter and more efficient than): | |
85 | ||
310672d6 | 86 | .\" As far as I can see, LinuxThreads reverses the two substeps |
f06b4f5c MK |
87 | .\" in the push and pop below. |
88 | .in +4n | |
89 | .nf | |
90 | int oldtype; | |
91 | ||
92 | pthread_cleanup_push(routine, arg); | |
93 | pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); | |
94 | \&... | |
95 | pthread_setcanceltype(oldtype, NULL); | |
96 | pthread_cleanup_pop(execute); | |
97 | .fi | |
98 | .in | |
99 | .\" SH VERSIONS | |
100 | .\" Available since glibc 2.0 | |
101 | .SH CONFORMING TO | |
c8f2dd47 | 102 | These functions are nonstandard GNU extensions; |
d603cc27 | 103 | hence the suffix "_np" (nonportable) in the names. |
f06b4f5c MK |
104 | .SH SEE ALSO |
105 | .BR pthread_cancel (3), | |
106 | .BR pthread_cleanup_push (3), | |
107 | .BR pthread_setcancelstate (3), | |
108 | .BR pthread_testcancel (3), | |
109 | .BR pthreads (7) |