1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the American National Standards Committee X3, on Information 6.\" Processing Systems. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. All advertising materials mentioning features or use of this software 17.\" must display the following acknowledgement: 18.\" This product includes software developed by the University of 19.\" California, Berkeley and its contributors. 20.\" 4. Neither the name of the University nor the names of its contributors 21.\" may be used to endorse or promote products derived from this software 22.\" without specific prior written permission. 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34.\" SUCH DAMAGE. 35.\" 36.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93 37.\" $FreeBSD$ 38.\" 39.Dd June 4, 1993 40.Dt SETJMP 3 41.Os 42.Sh NAME 43.Nm sigsetjmp , 44.Nm siglongjmp , 45.Nm setjmp , 46.Nm longjmp , 47.Nm _setjmp , 48.Nm _longjmp , 49.Nm longjmperror 50.Nd non-local jumps 51.Sh LIBRARY 52.Lb libc 53.Sh SYNOPSIS 54.In setjmp.h 55.Ft int 56.Fn sigsetjmp "sigjmp_buf env" "int savemask" 57.Ft void 58.Fn siglongjmp "sigjmp_buf env" "int val" 59.Ft int 60.Fn setjmp "jmp_buf env" 61.Ft void 62.Fn longjmp "jmp_buf env" "int val" 63.Ft int 64.Fn _setjmp "jmp_buf env" 65.Ft void 66.Fn _longjmp "jmp_buf env" "int val" 67.Ft void 68.Fn longjmperror void 69.Sh DESCRIPTION 70The 71.Fn sigsetjmp , 72.Fn setjmp , 73and 74.Fn _setjmp 75functions save their calling environment in 76.Fa env . 77Each of these functions returns 0. 78.Pp 79The corresponding 80.Fn longjmp 81functions restore the environment saved by their most recent respective 82invocations 83of the 84.Fn setjmp 85function. 86They then return so that program execution continues as if the corresponding 87invocation of the 88.Fn setjmp 89call had just returned the value specified by 90.Fa val , 91instead of 0. 92.Pp 93Pairs of calls may be intermixed, i.e., both 94.Fn sigsetjmp 95and 96.Fn siglongjmp 97and 98.Fn setjmp 99and 100.Fn longjmp 101combinations may be used in the same program, however, individual 102calls may not, e.g.\& the 103.Fa env 104argument to 105.Fn setjmp 106may not be passed to 107.Fn siglongjmp . 108.Pp 109The 110.Fn longjmp 111routines may not be called after the routine which called the 112.Fn setjmp 113routines returns. 114.Pp 115All accessible objects have values as of the time 116.Fn longjmp 117routine was called, except that the values of objects of automatic storage 118invocation duration that do not have the 119.Vt volatile 120type and have been changed between the 121.Fn setjmp 122invocation and 123.Fn longjmp 124call are indeterminate. 125.Pp 126The 127.Fn setjmp Ns / Ns Fn longjmp 128pairs save and restore the signal mask while 129.Fn _setjmp Ns / Ns Fn _longjmp 130pairs save and restore only the register set and the stack. 131(See 132.Fn sigprocmask 2 . ) 133.Pp 134The 135.Fn sigsetjmp Ns / Ns Fn siglongjmp 136function 137pairs save and restore the signal mask if the argument 138.Fa savemask 139is non-zero, otherwise only the register set and the stack are saved. 140.Sh ERRORS 141If the contents of the 142.Fa env 143are corrupted, or correspond to an environment that has already returned, 144the 145.Fn longjmp 146routine calls the routine 147.Fn longjmperror 3 . 148If 149.Fn longjmperror 150returns the program is aborted (see 151.Xr abort 3 ) . 152The default version of 153.Fn longjmperror 154prints the message 155.Dq Li longjmp botch 156to standard error and returns. 157User programs wishing to exit more gracefully should write their own 158versions of 159.Fn longjmperror . 160.Sh SEE ALSO 161.Xr sigaction 2 , 162.Xr sigaltstack 2 , 163.Xr signal 3 164.Sh STANDARDS 165The 166.Fn setjmp 167and 168.Fn longjmp 169functions conform to 170.St -isoC . 171The 172.Fn sigsetjmp 173and 174.Fn siglongjmp 175functions conform to 176.St -p1003.1-88 . 177