1pthread_cleanup_push(3C) Standard C Library Functions pthread_cleanup_push(3C)
2
3
4

NAME

6       pthread_cleanup_push - push a thread cancellation cleanup handler
7

SYNOPSIS

9       cc -mt [ flag... ] file... -lpthread [ library... ]
10       #include <pthread.h>
11
12       void pthread_cleanup_push(void (*handler) (void *), void *arg);
13
14

DESCRIPTION

16       The  pthread_cleanup_push()  function pushes the specified cancellation
17       cleanup handler routine, handler, onto the cancellation  cleanup  stack
18       of the calling thread.
19
20
21       When  a thread exits or is canceled and its cancellation cleanup  stack
22       is not empty, the cleanup handlers are invoked with the  argument   arg
23       in   last  in,  first  out  (LIFO)  order from the cancellation cleanup
24       stack.
25
26
27       An exiting or cancelled thread  runs  with  all  signals  blocked.  All
28       thread  termination functions, including cancellation cleanup handlers,
29       are called with all signals blocked.
30
31
32       The pthread_cleanup_push() and pthread_cleanup_pop(3C) functions can be
33       implemented  as macros. The application must ensure that they appear as
34       statements, and in pairs within the same lexical scope  (that  is,  the
35       pthread_cleanup_push()  macro  can be thought to expand to a token list
36       whose first token is '{'  with  pthread_cleanup_pop()  expanding  to  a
37       token list whose last token is the corresponding '}').
38
39
40       The  effect  of  the use of return, break, continue, and goto to prema‐
41       turely leave a code block described by a pair of pthread_cleanup_push()
42       and pthread_cleanup_pop() function calls is undefined.
43
44
45       Using  longjmp() or siglongjmp() to jump into or out of a push/pop pair
46       can cause either the matching push or the matching  pop  statement  not
47       getting executed.
48

RETURN VALUES

50       The pthread_cleanup_push() function returns no value.
51

ERRORS

53       No errors are defined.
54
55
56       The   pthread_cleanup_push()  function will not return an error code of
57       EINTR.
58

ATTRIBUTES

60       See attributes(5) for descriptions of the following attributes:
61
62
63
64
65       ┌─────────────────────────────┬─────────────────────────────┐
66       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
67       ├─────────────────────────────┼─────────────────────────────┤
68       │Interface Stability          │Committed                    │
69       ├─────────────────────────────┼─────────────────────────────┤
70       │MT-Level                     │MT-Safe                      │
71       ├─────────────────────────────┼─────────────────────────────┤
72       │Standard                     │See standards(5).            │
73       └─────────────────────────────┴─────────────────────────────┘
74

SEE ALSO

76       longjmp(3C),        pthread_cancel(3C),        pthread_cleanup_pop(3C),
77       pthread_exit(3C),     pthread_join(3C),     pthread_setcancelstate(3C),
78       pthread_setcanceltype(3C), pthread_testcancel(3C), attributes(5),  can‐
79       cellation(5), condition(5), standards(5)
80

NOTES

82       See cancellation(5) for a discussion of cancellation concepts.
83
84
85
86SunOS 5.11                        2 Nov 2007          pthread_cleanup_push(3C)
Impressum