summaryrefslogtreecommitdiffstats
path: root/man3/pthread_cleanup_push.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man3/pthread_cleanup_push.335
1 files changed, 17 insertions, 18 deletions
diff --git a/man3/pthread_cleanup_push.3 b/man3/pthread_cleanup_push.3
index 9fcccb3..eec8c8e 100644
--- a/man3/pthread_cleanup_push.3
+++ b/man3/pthread_cleanup_push.3
@@ -4,7 +4,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH pthread_cleanup_push 3 2023-07-20 "Linux man-pages 6.05.01"
+.TH pthread_cleanup_push 3 2023-10-31 "Linux man-pages 6.7"
.SH NAME
pthread_cleanup_push, pthread_cleanup_pop \- push and pop
thread cancelation clean-up handlers
@@ -14,7 +14,7 @@ POSIX threads library
.SH SYNOPSIS
.nf
.B #include <pthread.h>
-.PP
+.P
.BI "void pthread_cleanup_push(void (*" routine ")(void *), void *" arg );
.BI "void pthread_cleanup_pop(int " execute );
.fi
@@ -26,7 +26,7 @@ when a thread is canceled (or in various other circumstances
described below);
it might, for example, unlock a mutex so that
it becomes available to other threads in the process.
-.PP
+.P
The
.BR pthread_cleanup_push ()
function pushes
@@ -37,14 +37,14 @@ When
is later invoked, it will be given
.I arg
as its argument.
-.PP
+.P
The
.BR pthread_cleanup_pop ()
function removes the routine at the top of the stack of clean-up handlers,
and optionally executes it if
.I execute
is nonzero.
-.PP
+.P
A cancelation clean-up handler is popped from the stack
and executed in the following circumstances:
.IP \[bu] 3
@@ -67,7 +67,7 @@ When a thread calls
with a nonzero
.I execute
argument, the top-most clean-up handler is popped and executed.
-.PP
+.P
POSIX.1 permits
.BR pthread_cleanup_push ()
and
@@ -79,7 +79,7 @@ functions are paired within the same function,
and at the same lexical nesting level.
(In other words, a clean-up handler is established only
during the execution of a specified section of code.)
-.PP
+.P
Calling
.BR longjmp (3)
.RB ( siglongjmp (3))
@@ -118,7 +118,6 @@ T{
.BR pthread_cleanup_pop ()
T} Thread safety MT-Safe
.TE
-.sp 1
.SH VERSIONS
On glibc, the
.BR pthread_cleanup_push ()
@@ -130,7 +129,7 @@ implemented as macros that expand to text
containing \[aq]\fB{\fP\[aq] and \[aq]\fB}\fP\[aq], respectively.
This means that variables declared within the scope of
paired calls to these functions will be visible within only that scope.
-.PP
+.P
POSIX.1
.\" The text was actually added in the 2004 TC2
says that the effect of using
@@ -165,10 +164,10 @@ the main thread sends the other thread a cancelation request,
or sets a global variable that causes the other thread
to exit its loop and terminate normally (by doing a
.IR return ).
-.PP
+.P
In the following shell session,
the main thread sends a cancelation request to the other thread:
-.PP
+.P
.in +4n
.EX
$ \fB./a.out\fP
@@ -180,16 +179,16 @@ Called clean\-up handler
Thread was canceled; cnt = 0
.EE
.in
-.PP
+.P
From the above, we see that the thread was canceled,
and that the cancelation clean-up handler was called
and it reset the value of the global variable
.I cnt
to 0.
-.PP
+.P
In the next run, the main program sets a
global variable that causes other thread to terminate normally:
-.PP
+.P
.in +4n
.EX
$ \fB./a.out x\fP
@@ -199,18 +198,18 @@ cnt = 1
Thread terminated normally; cnt = 2
.EE
.in
-.PP
+.P
From the above, we see that the clean-up handler was not executed (because
.I cleanup_pop_arg
was 0), and therefore the value of
.I cnt
was not reset.
-.PP
+.P
In the next run, the main program sets a global variable that
causes the other thread to terminate normally,
and supplies a nonzero value for
.IR cleanup_pop_arg :
-.PP
+.P
.in +4n
.EX
$ \fB./a.out x 1\fP
@@ -221,7 +220,7 @@ Called clean\-up handler
Thread terminated normally; cnt = 0
.EE
.in
-.PP
+.P
In the above, we see that although the thread was not canceled,
the clean-up handler was executed, because the argument given to
.BR pthread_cleanup_pop ()