]>
Commit | Line | Data |
---|---|---|
f06b4f5c MK |
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
4 | .\" Permission is granted to make and distribute verbatim copies of this | |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
20 | .\" | |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
23 | .\" | |
24 | .TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2008-12-04 "Linux" "Linux Programmer's Manual" | |
25 | .SH NAME | |
26 | pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop | |
27 | thread cancellation clean-up handlers while saving cancelability type | |
28 | .SH SYNOPSIS | |
29 | .nf | |
30 | .B #include <pthread.h> | |
31 | ||
32 | .BI "void pthread_cleanup_push_defer_np(void (*" routine ")(void *)," | |
33 | .BI " void *" arg ); | |
34 | .BI "void pthread_cleanup_pop_restore_np(int " execute ); | |
35 | .sp | |
36 | Compile and link with \fI\-pthread\fP. | |
37 | .SH DESCRIPTION | |
38 | These functions are the same as | |
39 | .BR pthread_cleanup_push (3) | |
40 | and | |
41 | .BR pthread_cleanup_pop (3), | |
42 | except for the differences noted on this page. | |
43 | ||
44 | Like | |
45 | .BR pthread_cleanup_push (3), | |
46 | .BR pthread_cleanup_push_defer_np () | |
47 | pushes | |
48 | .I routine | |
49 | onto the thread's stack of cancellation clean-up handlers. | |
50 | In addition, it also saves the thread's current cancelability type, | |
51 | and sets the cancelability type to "deferred" (see | |
52 | .BR pthread_setcanceltype (3)); | |
53 | this ensures that cancellation clean-up will occur | |
54 | even if the thread's cancelability type was "asynchronous" | |
55 | before the the call. | |
56 | ||
57 | Like | |
58 | .BR pthread_cleanup_pop (3), | |
59 | .BR pthread_cleanup_pop_restore_np () | |
60 | pops the top-most clean-up handler from the thread's | |
61 | stack of cancellation clean-up handlers. | |
62 | In addition, it restores the thread's cancelability | |
63 | type to its value at the time of the matching | |
64 | .BR pthread_cleanup_push_defer_np (). | |
65 | ||
66 | The caller must ensure that calls to these | |
67 | functions are paired within the same function, | |
68 | and at the same lexical nesting level. | |
69 | Other restrictions apply, as described in | |
70 | .BR pthread_cleanup_push (3). | |
71 | ||
72 | This sequence of calls: | |
73 | ||
74 | .in +4n | |
75 | .nf | |
76 | pthread_cleanup_push_defer_np(routine, arg); | |
77 | pthread_cleanup_pop_restore_np(execute); | |
78 | .fi | |
79 | .in | |
80 | ||
81 | is equivalent to (but shorter and more efficient than): | |
82 | ||
83 | .\" As far as I can see, LinuxThreads reverses the two sub-steps | |
84 | .\" in the push and pop below. | |
85 | .in +4n | |
86 | .nf | |
87 | int oldtype; | |
88 | ||
89 | pthread_cleanup_push(routine, arg); | |
90 | pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); | |
91 | \&... | |
92 | pthread_setcanceltype(oldtype, NULL); | |
93 | pthread_cleanup_pop(execute); | |
94 | .fi | |
95 | .in | |
96 | .\" SH VERSIONS | |
97 | .\" Available since glibc 2.0 | |
98 | .SH CONFORMING TO | |
c8f2dd47 | 99 | These functions are nonstandard GNU extensions; |
f06b4f5c MK |
100 | hence the suffix "_np" (non-portable) in the names. |
101 | .SH SEE ALSO | |
102 | .BR pthread_cancel (3), | |
103 | .BR pthread_cleanup_push (3), | |
104 | .BR pthread_setcancelstate (3), | |
105 | .BR pthread_testcancel (3), | |
106 | .BR pthreads (7) |