1PTHREAD_CLEANUP_PUSH_DEFER_NLPi(n3u)x Programmer's MPaTnHuRaElAD_CLEANUP_PUSH_DEFER_NP(3)
2
3
4

NAME

6       pthread_cleanup_push_defer_np,  pthread_cleanup_pop_restore_np  -  push
7       and pop thread cancellation clean-up handlers while saving  cancelabil‐
8       ity type
9

SYNOPSIS

11       #include <pthread.h>
12
13       void pthread_cleanup_push_defer_np(void (*routine)(void *),
14                                          void *arg);
15       void pthread_cleanup_pop_restore_np(int execute);
16
17       Compile and link with -pthread.
18

DESCRIPTION

20       These   functions   are   the   same   as  pthread_cleanup_push(3)  and
21       pthread_cleanup_pop(3), except for the differences noted on this page.
22
23       Like  pthread_cleanup_push(3),  pthread_cleanup_push_defer_np()  pushes
24       routine  onto the thread's stack of cancellation clean-up handlers.  In
25       addition, it also saves the thread's current  cancelability  type,  and
26       sets  the  cancelability  type  to  "deferred"  (see pthread_setcancel‐
27       type(3)); this ensures that cancellation clean-up will  occur  even  if
28       the thread's cancelability type was "asynchronous" before the the call.
29
30       Like  pthread_cleanup_pop(3), pthread_cleanup_pop_restore_np() pops the
31       top-most clean-up handler  from  the  thread's  stack  of  cancellation
32       clean-up handlers.  In addition, it restores the thread's cancelability
33       type   to    its    value    at    the    time    of    the    matching
34       pthread_cleanup_push_defer_np().
35
36       The  caller must ensure that calls to these functions are paired within
37       the same function, and  at  the  same  lexical  nesting  level.   Other
38       restrictions apply, as described in pthread_cleanup_push(3).
39
40       This sequence of calls:
41
42           pthread_cleanup_push_defer_np(routine, arg);
43           pthread_cleanup_pop_restore_np(execute);
44
45       is equivalent to (but shorter and more efficient than):
46
47           int oldtype;
48
49           pthread_cleanup_push(routine, arg);
50           pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
51           ...
52           pthread_setcanceltype(oldtype, NULL);
53           pthread_cleanup_pop(execute);
54

CONFORMING TO

56       These  functions are nonstandard GNU extensions; hence the suffix "_np"
57       (nonportable) in the names.
58

SEE ALSO

60       pthread_cancel(3), pthread_cleanup_push(3),  pthread_setcancelstate(3),
61       pthread_testcancel(3), pthreads(7)
62

COLOPHON

64       This  page  is  part of release 3.25 of the Linux man-pages project.  A
65       description of the project, and information about reporting  bugs,  can
66       be found at http://www.kernel.org/doc/man-pages/.
67
68
69
70Linux                             2008-12-04  PTHREAD_CLEANUP_PUSH_DEFER_NP(3)
Impressum