|
Packit |
7cfc04 |
'\" et
|
|
Packit |
7cfc04 |
.TH PTHREAD_CANCEL "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH PROLOG
|
|
Packit |
7cfc04 |
This manual page is part of the POSIX Programmer's Manual.
|
|
Packit |
7cfc04 |
The Linux implementation of this interface may differ (consult
|
|
Packit |
7cfc04 |
the corresponding Linux manual page for details of Linux behavior),
|
|
Packit |
7cfc04 |
or the interface may not be implemented on Linux.
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
pthread_cancel
|
|
Packit |
7cfc04 |
\(em cancel execution of a thread
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
#include <pthread.h>
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
int pthread_cancel(pthread_t \fIthread\fP);
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIpthread_cancel\fR()
|
|
Packit |
7cfc04 |
function shall request that
|
|
Packit |
7cfc04 |
.IR thread
|
|
Packit |
7cfc04 |
be canceled. The target thread's cancelability state and type
|
|
Packit |
7cfc04 |
determines when the cancellation takes effect. When the cancellation
|
|
Packit |
7cfc04 |
is acted on, the cancellation cleanup handlers for
|
|
Packit |
7cfc04 |
.IR thread
|
|
Packit |
7cfc04 |
shall be called. When the last cancellation cleanup handler returns,
|
|
Packit |
7cfc04 |
the thread-specific data destructor functions shall be called for
|
|
Packit |
7cfc04 |
.IR thread .
|
|
Packit |
7cfc04 |
When the last destructor function returns,
|
|
Packit |
7cfc04 |
.IR thread
|
|
Packit |
7cfc04 |
shall be terminated.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The cancellation processing in the target thread shall run
|
|
Packit |
7cfc04 |
asynchronously with respect to the calling thread returning from
|
|
Packit |
7cfc04 |
\fIpthread_cancel\fR().
|
|
Packit |
7cfc04 |
.SH "RETURN VALUE"
|
|
Packit |
7cfc04 |
If successful, the
|
|
Packit |
7cfc04 |
\fIpthread_cancel\fR()
|
|
Packit |
7cfc04 |
function shall return zero; otherwise, an error number shall be
|
|
Packit |
7cfc04 |
returned to indicate the error.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIpthread_cancel\fR()
|
|
Packit |
7cfc04 |
function shall not return an error code of
|
|
Packit |
7cfc04 |
.BR [EINTR] .
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.IR "The following sections are informative."
|
|
Packit |
7cfc04 |
.SH EXAMPLES
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "APPLICATION USAGE"
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH RATIONALE
|
|
Packit |
7cfc04 |
Two alternative functions were considered for sending the cancellation
|
|
Packit |
7cfc04 |
notification to a thread. One would be to define a new SIGCANCEL
|
|
Packit |
7cfc04 |
signal that had the cancellation semantics when delivered; the other was
|
|
Packit |
7cfc04 |
to define the new
|
|
Packit |
7cfc04 |
\fIpthread_cancel\fR()
|
|
Packit |
7cfc04 |
function, which would trigger the cancellation semantics.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The advantage of a new signal was that so much of the delivery criteria
|
|
Packit |
7cfc04 |
were identical to that used when trying to deliver a signal that making
|
|
Packit |
7cfc04 |
cancellation notification a signal was seen as consistent. Indeed, many
|
|
Packit |
7cfc04 |
implementations implement cancellation using a special signal. On the
|
|
Packit |
7cfc04 |
other hand, there would be no signal functions that could be used with
|
|
Packit |
7cfc04 |
this signal except
|
|
Packit |
7cfc04 |
\fIpthread_kill\fR(),
|
|
Packit |
7cfc04 |
and the behavior of the delivered cancellation signal would be unlike
|
|
Packit |
7cfc04 |
any previously existing defined signal.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The benefits of a special function include the recognition that this
|
|
Packit |
7cfc04 |
signal would be defined because of the similar delivery criteria and
|
|
Packit |
7cfc04 |
that this is the only common behavior between a cancellation request and
|
|
Packit |
7cfc04 |
a signal. In addition, the cancellation delivery mechanism does not
|
|
Packit |
7cfc04 |
have to be implemented as a signal. There are also strong, if not
|
|
Packit |
7cfc04 |
stronger, parallels with language exception mechanisms than with
|
|
Packit |
7cfc04 |
signals that are potentially obscured if the delivery mechanism is
|
|
Packit |
7cfc04 |
visibly closer to signals.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
In the end, it was considered that as there were so many exceptions to
|
|
Packit |
7cfc04 |
the use of the new signal with existing signals functions it
|
|
Packit |
7cfc04 |
would be misleading. A special function has resolved this problem.
|
|
Packit |
7cfc04 |
This function was carefully defined so that an implementation wishing
|
|
Packit |
7cfc04 |
to provide the cancellation functions on top of signals could do so.
|
|
Packit |
7cfc04 |
The special function also means that implementations are not obliged
|
|
Packit |
7cfc04 |
to implement cancellation with signals.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If an implementation detects use of a thread ID after the end of its
|
|
Packit |
7cfc04 |
lifetime, it is recommended that the function should fail and report an
|
|
Packit |
7cfc04 |
.BR [ESRCH]
|
|
Packit |
7cfc04 |
error.
|
|
Packit |
7cfc04 |
.SH "FUTURE DIRECTIONS"
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "SEE ALSO"
|
|
Packit |
7cfc04 |
.ad l
|
|
Packit |
7cfc04 |
.IR "\fIpthread_exit\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIpthread_cond_timedwait\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIpthread_join\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIpthread_setcancelstate\fR\^(\|)"
|
|
Packit |
7cfc04 |
.ad b
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The Base Definitions volume of POSIX.1\(hy2008,
|
|
Packit |
7cfc04 |
.IR "\fB<pthread.h>\fP"
|
|
Packit |
7cfc04 |
.SH COPYRIGHT
|
|
Packit |
7cfc04 |
Portions of this text are reprinted and reproduced in electronic form
|
|
Packit |
7cfc04 |
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
|
|
Packit |
7cfc04 |
-- Portable Operating System Interface (POSIX), The Open Group Base
|
|
Packit |
7cfc04 |
Specifications Issue 7, Copyright (C) 2013 by the Institute of
|
|
Packit |
7cfc04 |
Electrical and Electronics Engineers, Inc and The Open Group.
|
|
Packit |
7cfc04 |
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
|
|
Packit |
7cfc04 |
event of any discrepancy between this version and the original IEEE and
|
|
Packit |
7cfc04 |
The Open Group Standard, the original IEEE and The Open Group Standard
|
|
Packit |
7cfc04 |
is the referee document. The original Standard can be obtained online at
|
|
Packit |
7cfc04 |
http://www.unix.org/online.html .
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
Any typographical or formatting errors that appear
|
|
Packit |
7cfc04 |
in this page are most likely
|
|
Packit |
7cfc04 |
to have been introduced during the conversion of the source files to
|
|
Packit |
7cfc04 |
man page format. To report such errors, see
|
|
Packit |
7cfc04 |
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|