1.\" $OpenBSD: pthread_cancel.3,v 1.13 2013/06/05 03:44:50 tedu Exp $ 2.\" 3.\" 4.\" David Leonard, 1999. Public Domain. 5.\" 6.Dd $Mdocdate: June 5 2013 $ 7.Dt PTHREAD_CANCEL 3 8.Os 9.Sh NAME 10.Nm pthread_cancel 11.Nd cancel execution of a thread 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 cancelled. 22The target thread's cancelability state and type determines 23when the cancellation takes effect. 24When the cancellation is acted on, the 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 constant 42.Dv PTHREAD_CANCELED 43expands to a constant expression of type 44.Ft "(void *)" 45whose value matches no pointer to an object in memory nor the value 46.Dv NULL . 47.Sh RETURN VALUES 48If successful, the 49.Fn pthread_cancel 50functions will return zero. 51Otherwise an error number will be returned to indicate the error. 52.Sh ERRORS 53.Fn pthread_cancel 54will fail if: 55.Bl -tag -width Er 56.It Bq Er ESRCH 57No thread could be found corresponding to that specified by the given 58thread ID. 59.El 60.Sh SEE ALSO 61.Xr pthread_cleanup_pop 3 , 62.Xr pthread_cleanup_push 3 , 63.Xr pthread_exit 3 , 64.Xr pthread_join 3 , 65.Xr pthread_setcancelstate 3 , 66.Xr pthread_setcanceltype 3 , 67.Xr pthread_testcancel 3 68.Sh STANDARDS 69.Fn pthread_cancel 70conforms to 71.St -p1003.1-96 . 72