'\" te .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved. .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. .\" This notice shall appear on any product containing this material. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH pthread_testcancel 3C "23 Mar 2005" "SunOS 5.11" "Standard C Library Functions" .SH NAME pthread_testcancel \- create cancellation point in the calling thread .SH SYNOPSIS .LP .nf cc -mt [ \fIflag\fR... ] \fIfile\fR... -lpthread [ \fIlibrary\fR... ] #include \fBvoid\fR \fBpthread_testcancel\fR(\fBvoid\fR); .fi .SH DESCRIPTION .sp .LP The \fBpthread_testcancel()\fR function forces testing for cancellation. This is useful when you need to execute code that runs for long periods without encountering cancellation points; such as a library routine that executes long-running computations without cancellation points. This type of code can block cancellation for unacceptable long periods of time. One strategy for avoiding blocking cancellation for long periods, is to insert calls to \fBpthread_testcancel()\fR in the long-running computation code and to setup a cancellation handler in the library code, if required. .SH RETURN VALUES .sp .LP The \fBpthread_testcancel()\fR function returns \fBvoid\fR. .SH ERRORS .sp .LP The \fBpthread_testcancel()\fR function does not return errors. .SH EXAMPLES .sp .LP See \fBcancellation\fR(5) for an example of using \fBpthread_testcancel()\fR to force testing for cancellation and a discussion of cancellation concepts. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityStandard _ MT-LevelMT-Safe .TE .SH SEE ALSO .sp .LP \fBIntro\fR(3), \fBpthread_cleanup_pop\fR(3C), \fBpthread_cleanup_push\fR(3C), \fBpthread_exit\fR(3C), \fBpthread_join\fR(3C), \fBpthread_setcancelstate\fR(3C), \fBpthread_setcanceltype\fR(3C), \fBsetjmp\fR(3C), \fBattributes\fR(5), \fBcancellation\fR(5), \fBcondition\fR(5), \fBstandards\fR(5) .SH NOTES .sp .LP The \fBpthread_testcancel()\fR function has no effect if cancellation is disabled. .sp .LP Use \fBpthread_testcancel()\fR with \fBpthread_setcanceltype()\fR called with its \fIcanceltype\fR set to \fBPTHREAD_CANCEL_DEFERRED\fR. The \fBpthread_testcancel()\fR function operation is undefined if \fBpthread_setcanceltype()\fR was called with its \fIcanceltype\fR argument set to \fBPTHREAD_CANCEL_ASYNCHRONOUS\fR. .sp .LP It is possible to kill a thread when it is holding a resource, such as lock or allocated memory. If that thread has not setup a cancellation cleanup handler to release the held resource, the application is "cancel-unsafe". See \fBattributes\fR(5) for a discussion of Cancel-Safety, Deferred-Cancel-Safety, and Asynchronous-Cancel-Safety.