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