]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_cleanup_push_defer_np.3
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[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.\"
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
28pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop
29thread 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
39Compile and link with \fI\-pthread\fP.
40.SH DESCRIPTION
41These functions are the same as
42.BR pthread_cleanup_push (3)
43and
44.BR pthread_cleanup_pop (3),
45except for the differences noted on this page.
46
47Like
48.BR pthread_cleanup_push (3),
49.BR pthread_cleanup_push_defer_np ()
50pushes
51.I routine
52onto the thread's stack of cancellation clean-up handlers.
53In addition, it also saves the thread's current cancelability type,
54and sets the cancelability type to "deferred" (see
55.BR pthread_setcanceltype (3));
56this ensures that cancellation clean-up will occur
57even if the thread's cancelability type was "asynchronous"
b084fc29 58before the call.
f06b4f5c
MK
59
60Like
61.BR pthread_cleanup_pop (3),
62.BR pthread_cleanup_pop_restore_np ()
63pops the top-most clean-up handler from the thread's
64stack of cancellation clean-up handlers.
65In addition, it restores the thread's cancelability
66type to its value at the time of the matching
67.BR pthread_cleanup_push_defer_np ().
68
69The caller must ensure that calls to these
70functions are paired within the same function,
71and at the same lexical nesting level.
72Other restrictions apply, as described in
73.BR pthread_cleanup_push (3).
74
75This sequence of calls:
76
77.in +4n
78.nf
79pthread_cleanup_push_defer_np(routine, arg);
80pthread_cleanup_pop_restore_np(execute);
81.fi
82.in
83
84is 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
90int oldtype;
91
92pthread_cleanup_push(routine, arg);
93pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
94\&...
95pthread_setcanceltype(oldtype, NULL);
96pthread_cleanup_pop(execute);
97.fi
98.in
99.\" SH VERSIONS
100.\" Available since glibc 2.0
101.SH CONFORMING TO
c8f2dd47 102These functions are nonstandard GNU extensions;
d603cc27 103hence 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)