1.\" $FreeBSD$ 2.Dd January 17, 1999 3.Dt PTHREAD_CANCEL 3 4.Os 5.Sh NAME 6.Nm pthread_cancel 7.Nd cancel execution of a thread 8.Sh LIBRARY 9.Lb libc_r 10.Lb libpthread 11.Sh SYNOPSIS 12.In pthread.h 13.Ft int 14.Fn pthread_cancel "pthread_t thread" 15.Sh DESCRIPTION 16The 17.Fn pthread_cancel 18function requests that 19.Fa thread 20be canceled. 21The target thread's cancelability state and type determines 22when the cancellation takes effect. 23When the cancellation is acted on, 24the cancellation cleanup handlers for 25.Fa thread 26are called. 27When the last cancellation cleanup handler returns, 28the thread-specific data destructor functions will be called for 29.Fa thread . 30When the last destructor function returns, 31.Fa thread 32will be terminated. 33.Pp 34The cancellation processing in the target thread runs asynchronously with 35respect to the calling thread returning from 36.Fn pthread_cancel . 37.Pp 38A status of 39.Dv PTHREAD_CANCELED 40is made available to any threads joining with the target. 41The symbolic 42constant 43.Dv PTHREAD_CANCELED 44expands to a constant expression of type 45.Ft "(void *)" , 46whose value matches no pointer to an object in memory nor the value 47.Dv NULL . 48.Sh RETURN VALUES 49If successful, the 50.Fn pthread_cancel 51functions will return zero. 52Otherwise an error number will be returned to 53indicate the error. 54.Sh ERRORS 55The 56.Fn pthread_cancel 57function will fail if: 58.Bl -tag -width Er 59.It Bq Er ESRCH 60No thread could be found corresponding to that specified by the given 61thread ID. 62.El 63.Sh SEE ALSO 64.Xr pthread_cleanup_pop 3 , 65.Xr pthread_cleanup_push 3 , 66.Xr pthread_exit 3 , 67.Xr pthread_join 3 , 68.Xr pthread_setcancelstate 3 , 69.Xr pthread_setcanceltype 3 , 70.Xr pthread_testcancel 3 71.Sh STANDARDS 72The 73.Fn pthread_cancel 74function conforms to 75.St -p1003.1-96 . 76.Sh AUTHORS 77This man page was written by 78.An David Leonard Aq d@openbsd.org 79for the 80.Ox 81implementation of 82.Fn pthread_cancel . 83