~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "PTHREAD_CANCEL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" pthread_cancel 
4
.SH NAME
5
pthread_cancel \- cancel execution of a thread
6
.SH SYNOPSIS
7
.LP
8
\fB#include <pthread.h>
9
.br
10
.sp
11
int pthread_cancel(pthread_t\fP \fIthread\fP\fB); \fP
12
\fB
13
.br
14
\fP
15
.SH DESCRIPTION
16
.LP
17
The \fIpthread_cancel\fP() function shall request that \fIthread\fP
18
be canceled. The target thread's cancelability state and
19
type determines when the cancellation takes effect. When the cancellation
20
is acted on, the cancellation cleanup handlers for
21
\fIthread\fP shall be called. When the last cancellation cleanup handler
22
returns, the thread-specific data destructor functions
23
shall be called for \fIthread\fP. When the last destructor function
24
returns, \fIthread\fP shall be terminated.
25
.LP
26
The cancellation processing in the target thread shall run asynchronously
27
with respect to the calling thread returning from
28
\fIpthread_cancel\fP().
29
.SH RETURN VALUE
30
.LP
31
If successful, the \fIpthread_cancel\fP() function shall return zero;
32
otherwise, an error number shall be returned to indicate
33
the error.
34
.SH ERRORS
35
.LP
36
The \fIpthread_cancel\fP() function may fail if:
37
.TP 7
38
.B ESRCH
39
No thread could be found corresponding to that specified by the given
40
thread ID.
41
.sp
42
.LP
43
The \fIpthread_cancel\fP() function shall not return an error code
44
of [EINTR].
45
.LP
46
\fIThe following sections are informative.\fP
47
.SH EXAMPLES
48
.LP
49
None.
50
.SH APPLICATION USAGE
51
.LP
52
None.
53
.SH RATIONALE
54
.LP
55
Two alternative functions were considered for sending the cancellation
56
notification to a thread. One would be to define a new
57
SIGCANCEL signal that had the cancellation semantics when delivered;
58
the other was to define the new \fIpthread_cancel\fP()
59
function, which would trigger the cancellation semantics.
60
.LP
61
The advantage of a new signal was that so much of the delivery criteria
62
were identical to that used when trying to deliver a
63
signal that making cancellation notification a signal was seen as
64
consistent. Indeed, many implementations implement cancellation
65
using a special signal. On the other hand, there would be no signal
66
functions that could be used with this signal except \fIpthread_kill\fP(),
67
and the behavior of the delivered cancellation signal would be unlike
68
any previously existing defined signal.
69
.LP
70
The benefits of a special function include the recognition that this
71
signal would be defined because of the similar delivery
72
criteria and that this is the only common behavior between a cancellation
73
request and a signal. In addition, the cancellation
74
delivery mechanism does not have to be implemented as a signal. There
75
are also strong, if not stronger, parallels with language
76
exception mechanisms than with signals that are potentially obscured
77
if the delivery mechanism is visibly closer to signals.
78
.LP
79
In the end, it was considered that as there were so many exceptions
80
to the use of the new signal with existing signals functions
81
it would be misleading. A special function has resolved this problem.
82
This function was carefully defined so that an implementation
83
wishing to provide the cancellation functions on top of signals could
84
do so. The special function also means that implementations
85
are not obliged to implement cancellation with signals.
86
.SH FUTURE DIRECTIONS
87
.LP
88
None.
89
.SH SEE ALSO
90
.LP
91
\fIpthread_exit\fP() , \fIpthread_cond_timedwait\fP() , \fIpthread_join\fP()
92
, \fIpthread_setcancelstate\fP() , the Base Definitions volume of
93
IEEE\ Std\ 1003.1-2001, \fI<pthread.h>\fP
94
.SH COPYRIGHT
95
Portions of this text are reprinted and reproduced in electronic form
96
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97
-- Portable Operating System Interface (POSIX), The Open Group Base
98
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
99
Electrical and Electronics Engineers, Inc and The Open Group. In the
100
event of any discrepancy between this version and the original IEEE and
101
The Open Group Standard, the original IEEE and The Open Group Standard
102
is the referee document. The original Standard can be obtained online at
103
http://www.opengroup.org/unix/online.html .