11fbdc08dSPoul-Henning Kamp.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> 21fbdc08dSPoul-Henning Kamp.\" All rights reserved. 31fbdc08dSPoul-Henning Kamp.\" 41fbdc08dSPoul-Henning Kamp.\" Redistribution and use in source and binary forms, with or without 51fbdc08dSPoul-Henning Kamp.\" modification, are permitted provided that the following conditions 61fbdc08dSPoul-Henning Kamp.\" are met: 71fbdc08dSPoul-Henning Kamp.\" 1. Redistributions of source code must retain the above copyright 81fbdc08dSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer. 91fbdc08dSPoul-Henning Kamp.\" 2. Redistributions in binary form must reproduce the above copyright 101fbdc08dSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer in the 111fbdc08dSPoul-Henning Kamp.\" documentation and/or other materials provided with the distribution. 121fbdc08dSPoul-Henning Kamp.\" 3. Neither the name of the author nor the names of any co-contributors 131fbdc08dSPoul-Henning Kamp.\" may be used to endorse or promote products derived from this software 141fbdc08dSPoul-Henning Kamp.\" without specific prior written permission. 151fbdc08dSPoul-Henning Kamp.\" 161fbdc08dSPoul-Henning Kamp.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 171fbdc08dSPoul-Henning Kamp.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181fbdc08dSPoul-Henning Kamp.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191fbdc08dSPoul-Henning Kamp.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 201fbdc08dSPoul-Henning Kamp.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211fbdc08dSPoul-Henning Kamp.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221fbdc08dSPoul-Henning Kamp.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231fbdc08dSPoul-Henning Kamp.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241fbdc08dSPoul-Henning Kamp.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251fbdc08dSPoul-Henning Kamp.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261fbdc08dSPoul-Henning Kamp.\" SUCH DAMAGE. 271fbdc08dSPoul-Henning Kamp.\" 28*613a9773SJohn Baldwin.Dd October 25, 2014 291fbdc08dSPoul-Henning Kamp.Dt PTHREAD_CLEANUP_PUSH 3 30a307d598SRuslan Ermilov.Os 311fbdc08dSPoul-Henning Kamp.Sh NAME 321fbdc08dSPoul-Henning Kamp.Nm pthread_cleanup_push 331fbdc08dSPoul-Henning Kamp.Nd add a cleanup function for thread exit 34d8a78688SAlexey Zelkin.Sh LIBRARY 35ec7452f1SRuslan Ermilov.Lb libpthread 361fbdc08dSPoul-Henning Kamp.Sh SYNOPSIS 3732eef9aeSRuslan Ermilov.In pthread.h 381fbdc08dSPoul-Henning Kamp.Ft void 39108b08b2SRuslan Ermilov.Fn pthread_cleanup_push "void \*[lp]*cleanup_routine\*[rp]\*[lp]void *\*[rp]" "void *arg" 401fbdc08dSPoul-Henning Kamp.Sh DESCRIPTION 411fbdc08dSPoul-Henning KampThe 421fbdc08dSPoul-Henning Kamp.Fn pthread_cleanup_push 431fbdc08dSPoul-Henning Kampfunction adds 441fbdc08dSPoul-Henning Kamp.Fa cleanup_routine 451fbdc08dSPoul-Henning Kampto the top of the stack of cleanup handlers that 461fbdc08dSPoul-Henning Kampget called when the current thread exits. 471fbdc08dSPoul-Henning Kamp.Pp 481fbdc08dSPoul-Henning KampWhen 49108b08b2SRuslan Ermilov.Fa cleanup_routine 501fbdc08dSPoul-Henning Kampis called, it is passed 511fbdc08dSPoul-Henning Kamp.Fa arg 521fbdc08dSPoul-Henning Kampas its only argument. 53*613a9773SJohn Baldwin.Pp 54*613a9773SJohn BaldwinThe 55*613a9773SJohn Baldwin.Fn pthread_cleanup_push 56*613a9773SJohn Baldwinfunction is implemented as a macro that opens a new block. 57*613a9773SJohn BaldwinInvocations of this function must appear as standalone statements that are 58*613a9773SJohn Baldwinpaired with a later call of 59*613a9773SJohn Baldwin.Xr pthread_cleanup_pop 3 60*613a9773SJohn Baldwinin the same lexical scope. 611fbdc08dSPoul-Henning Kamp.Sh RETURN VALUES 626f673fd1SPhilippe CharnierThe 631fbdc08dSPoul-Henning Kamp.Fn pthread_cleanup_push 646f673fd1SPhilippe Charnierfunction does not return any value. 651fbdc08dSPoul-Henning Kamp.Sh ERRORS 661fbdc08dSPoul-Henning KampNone 671fbdc08dSPoul-Henning Kamp.Sh SEE ALSO 681fbdc08dSPoul-Henning Kamp.Xr pthread_cleanup_pop 3 , 691fbdc08dSPoul-Henning Kamp.Xr pthread_exit 3 701fbdc08dSPoul-Henning Kamp.Sh STANDARDS 716f673fd1SPhilippe CharnierThe 721fbdc08dSPoul-Henning Kamp.Fn pthread_cleanup_push 736f673fd1SPhilippe Charnierfunction conforms to 74096841ecSRuslan Ermilov.St -p1003.1-96 . 75