1.\" $NetBSD: pthread_cleanup_push.3,v 1.2 2003/06/08 06:44:29 thorpej Exp $ 2.\" 3.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. Neither the name of The NetBSD Foundation nor the names of its 14.\" contributors may be used to endorse or promote products derived 15.\" from this software without specific prior written permission. 16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26.\" POSSIBILITY OF SUCH DAMAGE. 27.\" 28.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> 29.\" All rights reserved. 30.\" 31.\" Redistribution and use in source and binary forms, with or without 32.\" modification, are permitted provided that the following conditions 33.\" are met: 34.\" 1. Redistributions of source code must retain the above copyright 35.\" notice, this list of conditions and the following disclaimer. 36.\" 2. Redistributions in binary form must reproduce the above copyright 37.\" notice, this list of conditions and the following disclaimer in the 38.\" documentation and/or other materials provided with the distribution. 39.\" 3. Neither the name of the author nor the names of any co-contributors 40.\" may be used to endorse or promote products derived from this software 41.\" without specific prior written permission. 42.\" 43.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 44.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 46.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 47.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 49.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53.\" SUCH DAMAGE. 54.\" 55.\" $FreeBSD: src/lib/libpthread/man/pthread_cleanup_push.3,v 1.11 2002/09/16 19:29:28 mini Exp $ 56.\" 57.Dd January 30, 2003 58.Dt PTHREAD_CLEANUP 3 59.Os 60.Sh NAME 61.Nm pthread_cleanup_push , 62.Nm pthread_cleanup_pop 63.Nd add and remove cleanup functions for thread exit 64.Sh LIBRARY 65.Lb libpthread 66.Sh SYNOPSIS 67.In pthread.h 68.Ft void 69.Fn pthread_cleanup_push "void \*[lp]*cleanup_routine\*[rp]\*[lp]void *\*[rp]" "void *arg" 70.Ft void 71.Fn pthread_cleanup_pop "int execute" 72.Sh DESCRIPTION 73The 74.Fn pthread_cleanup_push 75function adds 76.Fa cleanup_routine 77to the top of the stack of cleanup handlers that 78get called when the current thread exits. 79.Pp 80.Pp 81The 82.Fn pthread_cleanup_pop 83function pops the top cleanup routine off of the current threads cleanup 84routine stack, and, if 85.Fa execute 86is non-zero, it will execute the function. 87.Pp 88When 89.Fa cleanup_routine 90is called, it is passed 91.Fa arg 92as its only argument. 93.Pp 94These functions may be implemented as macros which contain scope delimiters; 95therefore, there must be a matching 96.Fn pthread_cleanup_pop 97for every 98.Fn pthread_cleanup_push 99at the same level of lexical scoping. 100.Pp 101The effect of calling 102.Fn longjmp 103or 104.Fn siglongjmp 105is undefined after a call to 106.Fn pthread_cleanup_push 107but before the matching call to 108.Fn pthread_cleanup_pop 109after the jump buffer was filled. 110.Sh RETURN VALUES 111Neither 112.Fn pthread_cleanup_push 113nor 114.Fn pthread_cleanup_pop 115returns a value. 116.Sh ERRORS 117None. 118.Sh SEE ALSO 119.Xr pthread_exit 3 120.Sh STANDARDS 121.Fn pthread_cleanup_push 122and 123.Fn pthread_cleanup_pop 124conform to 125.St -p1003.1-96 . 126