]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_cleanup_push_defer_np.3
utimensat.2, wait.2, end.3: srcfix: remove duplicate words in comments
[thirdparty/man-pages.git] / man3 / pthread_cleanup_push_defer_np.3
CommitLineData
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
26pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop
27thread 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
36Compile and link with \fI\-pthread\fP.
37.SH DESCRIPTION
38These functions are the same as
39.BR pthread_cleanup_push (3)
40and
41.BR pthread_cleanup_pop (3),
42except for the differences noted on this page.
43
44Like
45.BR pthread_cleanup_push (3),
46.BR pthread_cleanup_push_defer_np ()
47pushes
48.I routine
49onto the thread's stack of cancellation clean-up handlers.
50In addition, it also saves the thread's current cancelability type,
51and sets the cancelability type to "deferred" (see
52.BR pthread_setcanceltype (3));
53this ensures that cancellation clean-up will occur
54even if the thread's cancelability type was "asynchronous"
55before the the call.
56
57Like
58.BR pthread_cleanup_pop (3),
59.BR pthread_cleanup_pop_restore_np ()
60pops the top-most clean-up handler from the thread's
61stack of cancellation clean-up handlers.
62In addition, it restores the thread's cancelability
63type to its value at the time of the matching
64.BR pthread_cleanup_push_defer_np ().
65
66The caller must ensure that calls to these
67functions are paired within the same function,
68and at the same lexical nesting level.
69Other restrictions apply, as described in
70.BR pthread_cleanup_push (3).
71
72This sequence of calls:
73
74.in +4n
75.nf
76pthread_cleanup_push_defer_np(routine, arg);
77pthread_cleanup_pop_restore_np(execute);
78.fi
79.in
80
81is equivalent to (but shorter and more efficient than):
82
310672d6 83.\" As far as I can see, LinuxThreads reverses the two substeps
f06b4f5c
MK
84.\" in the push and pop below.
85.in +4n
86.nf
87int oldtype;
88
89pthread_cleanup_push(routine, arg);
90pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
91\&...
92pthread_setcanceltype(oldtype, NULL);
93pthread_cleanup_pop(execute);
94.fi
95.in
96.\" SH VERSIONS
97.\" Available since glibc 2.0
98.SH CONFORMING TO
c8f2dd47 99These functions are nonstandard GNU extensions;
d603cc27 100hence the suffix "_np" (nonportable) in the names.
f06b4f5c
MK
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)