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