xref: /netbsd-src/lib/libpthread/pthread_cancel.3 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\" $NetBSD: pthread_cancel.3,v 1.2 2003/06/08 06:44:29 thorpej Exp $
2.\"
3.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of The NetBSD Foundation nor the names of its
14.\"    contributors may be used to endorse or promote products derived
15.\"    from this software without specific prior written permission.
16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26.\" POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD: src/lib/libpthread/man/pthread_cancel.3,v 1.7 2002/09/16 19:29:28 mini Exp $
29.Dd January 30, 2003
30.Dt PTHREAD_CANCEL 3
31.Os
32.Sh NAME
33.Nm pthread_cancel
34.Nd cancel execution of a thread
35.Sh LIBRARY
36.Lb libpthread
37.Sh SYNOPSIS
38.In pthread.h
39.Ft int
40.Fn pthread_cancel "pthread_t thread"
41.Sh DESCRIPTION
42The
43.Fn pthread_cancel
44function requests that
45.Fa thread
46be canceled.
47The target thread's cancelability state and type determines
48when the cancellation takes effect.
49When the cancellation is acted on,
50the cancellation cleanup handlers for
51.Fa thread
52are called.
53When the last cancellation cleanup handler returns,
54the thread-specific data destructor functions will be called for
55.Fa thread .
56When the last destructor function returns,
57.Fa thread
58will be terminated.
59.Pp
60The cancellation processing in the target thread runs asynchronously with
61respect to the calling thread returning from
62.Fn pthread_cancel .
63.Pp
64A status of
65.Dv PTHREAD_CANCELED
66is made available to any threads joining with the target.
67The symbolic
68constant
69.Dv PTHREAD_CANCELED
70expands to a constant expression of type
71.Ft (void *) ,
72whose value matches no pointer to an object in memory nor the value
73.Dv NULL .
74.Sh RETURN VALUES
75If successful,  the
76.Fn pthread_cancel
77functions will return zero.
78Otherwise an error number will be returned to
79indicate the error.
80.Sh ERRORS
81.Fn pthread_cancel
82may fail if:
83.Bl -tag -width Er
84.It Bq Er ESRCH
85No thread could be found corresponding to that specified by the given
86thread ID.
87.El
88.Sh SEE ALSO
89.Xr pthread_cleanup_pop 3 ,
90.Xr pthread_cleanup_push 3 ,
91.Xr pthread_exit 3 ,
92.Xr pthread_join 3 ,
93.Xr pthread_setcancelstate 3 ,
94.Xr pthread_setcanceltype 3 ,
95.Xr pthread_testcancel 3
96.Sh STANDARDS
97.Fn pthread_cancel
98conforms to
99.St -p1003.1-96 .
100.Sh AUTHORS
101This man page was written by
102.An David Leonard Aq d@openbsd.org
103for the
104.Ox
105implementation of
106.Fn pthread_cancel .
107