1.\" $OpenBSD: pthread_cancel.3,v 1.7 2001/06/24 18:17:30 jasoni Exp $ 2.Dd January 17, 1999 3.Dt PTHREAD_CANCEL 3 4.Os 5.Sh NAME 6.Nm pthread_cancel , 7.Nm pthread_setcancelstate , 8.Nm pthread_setcanceltype 9.Nd cancel execution of a thread 10.Sh SYNOPSIS 11.Fd #include <pthread.h> 12.Ft int 13.Fn pthread_cancel "pthread_t thread" 14.Ft int 15.Fn pthread_setcancelstate "int state" "int *oldstate" 16.Ft int 17.Fn pthread_setcanceltype "int type" "int *oldtype" 18.Sh DESCRIPTION 19The 20.Fn pthread_cancel 21function requests that 22.Fa thread 23be cancelled. The target thread's cancelability state and type determines 24when the cancellation takes effect. When the cancellation is acted on, 25the cancellation cleanup handlers for 26.Fa thread 27are called. When 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. The symbolic 41constant 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. Otherwise an error number will be returned to 51indicate 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 , 70.Fn pthread_setcancelstate , 71and 72.Fn pthread_setcanceltype 73conform to ISO/IEC 9945-1 ANSI/IEEE 74.Pq Dq Tn POSIX 75Std 1003.1 Second Edition 1996-07-12. 76