xref: /openbsd-src/lib/libpthread/man/pthread_cancel.3 (revision 86f9d4cdda0e0267dccd8755ac0035525579c4a7)
1*86f9d4cdStedu.\" $OpenBSD: pthread_cancel.3,v 1.13 2013/06/05 03:44:50 tedu Exp $
2084a1742Sjmc.\"
3084a1742Sjmc.\"
4084a1742Sjmc.\"  David Leonard, 1999. Public Domain.
582d2d131Sfgsch.\"
6*86f9d4cdStedu.Dd $Mdocdate: June 5 2013 $
77f5d363bSd.Dt PTHREAD_CANCEL 3
8c043c0f7Sd.Os
97f5d363bSd.Sh NAME
10aeae2ef9Sfgsch.Nm pthread_cancel
117f5d363bSd.Nd cancel execution of a thread
127f5d363bSd.Sh SYNOPSIS
13*86f9d4cdStedu.In pthread.h
147f5d363bSd.Ft int
157f5d363bSd.Fn pthread_cancel "pthread_t thread"
167f5d363bSd.Sh DESCRIPTION
177f5d363bSdThe
187f5d363bSd.Fn pthread_cancel
197f5d363bSdfunction requests that
207f5d363bSd.Fa thread
21ee997aeaSmpechbe cancelled.
22ee997aeaSmpechThe target thread's cancelability state and type determines
23ee997aeaSmpechwhen the cancellation takes effect.
24ee997aeaSmpechWhen the cancellation is acted on, the cancellation cleanup handlers for
257f5d363bSd.Fa thread
26ee997aeaSmpechare called.
27ee997aeaSmpechWhen the last cancellation cleanup handler returns,
287f5d363bSdthe thread-specific data destructor functions will be called for
297f5d363bSd.Fa thread .
307f5d363bSdWhen the last destructor function returns,
317f5d363bSd.Fa thread
327f5d363bSdwill be terminated.
337f5d363bSd.Pp
347f5d363bSdThe cancellation processing in the target thread runs asynchronously with
357f5d363bSdrespect to the calling thread returning from
367f5d363bSd.Fn pthread_cancel .
377f5d363bSd.Pp
387f5d363bSdA status of
397f5d363bSd.Dv PTHREAD_CANCELED
40ee997aeaSmpechis made available to any threads joining with the target.
41ee997aeaSmpechThe symbolic constant
427f5d363bSd.Dv PTHREAD_CANCELED
437f5d363bSdexpands to a constant expression of type
4498bd1583Sd.Ft "(void *)"
457f5d363bSdwhose value matches no pointer to an object in memory nor the value
467f5d363bSd.Dv NULL .
477f5d363bSd.Sh RETURN VALUES
487f5d363bSdIf successful, the
497f5d363bSd.Fn pthread_cancel
50ee997aeaSmpechfunctions will return zero.
51ee997aeaSmpechOtherwise an error number will be returned to indicate the error.
527f5d363bSd.Sh ERRORS
537f5d363bSd.Fn pthread_cancel
547f5d363bSdwill fail if:
557f5d363bSd.Bl -tag -width Er
567f5d363bSd.It Bq Er ESRCH
577f5d363bSdNo thread could be found corresponding to that specified by the given
587f5d363bSdthread ID.
597f5d363bSd.El
607f5d363bSd.Sh SEE ALSO
617f5d363bSd.Xr pthread_cleanup_pop 3 ,
627f5d363bSd.Xr pthread_cleanup_push 3 ,
637f5d363bSd.Xr pthread_exit 3 ,
64350bb3b8Salex.Xr pthread_join 3 ,
65350bb3b8Salex.Xr pthread_setcancelstate 3 ,
66350bb3b8Salex.Xr pthread_setcanceltype 3 ,
67350bb3b8Salex.Xr pthread_testcancel 3
687f5d363bSd.Sh STANDARDS
69aeae2ef9Sfgsch.Fn pthread_cancel
7082d2d131Sfgschconforms to
7182d2d131Sfgsch.St -p1003.1-96 .
72