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: src/lib/libc/gen/setjmp.3,v 1.5.2.5 2003/03/15 15:11:05 trhodes Exp $ 38.\" $DragonFly: src/lib/libc/gen/setjmp.3,v 1.2 2003/06/17 04:26:42 dillon Exp $ 39.\" 40.Dd June 4, 1993 41.Dt SETJMP 3 42.Os 43.Sh NAME 44.Nm sigsetjmp , 45.Nm siglongjmp , 46.Nm setjmp , 47.Nm longjmp , 48.Nm _setjmp , 49.Nm _longjmp , 50.Nm longjmperror 51.Nd non-local jumps 52.Sh LIBRARY 53.Lb libc 54.Sh SYNOPSIS 55.In setjmp.h 56.Ft int 57.Fn sigsetjmp "sigjmp_buf env" "int savemask" 58.Ft void 59.Fn siglongjmp "sigjmp_buf env" "int val" 60.Ft int 61.Fn setjmp "jmp_buf env" 62.Ft void 63.Fn longjmp "jmp_buf env" "int val" 64.Ft int 65.Fn _setjmp "jmp_buf env" 66.Ft void 67.Fn _longjmp "jmp_buf env" "int val" 68.Ft void 69.Fn longjmperror void 70.Sh DESCRIPTION 71The 72.Fn sigsetjmp , 73.Fn setjmp , 74and 75.Fn _setjmp 76functions save their calling environment in 77.Fa env . 78Each of these functions returns 0. 79.Pp 80The corresponding 81.Fn longjmp 82functions restore the environment saved by their most recent respective 83invocations 84of the 85.Fn setjmp 86function. 87They then return so that program execution continues as if the corresponding 88invocation of the 89.Fn setjmp 90call had just returned the value specified by 91.Fa val , 92instead of 0. 93.Pp 94Pairs of calls may be intermixed, i.e. both 95.Fn sigsetjmp 96and 97.Fn siglongjmp 98and 99.Fn setjmp 100and 101.Fn longjmp 102combinations may be used in the same program, however, individual 103calls may not, e.g. the 104.Fa env 105argument to 106.Fn setjmp 107may not be passed to 108.Fn siglongjmp . 109.Pp 110The 111.Fn longjmp 112routines may not be called after the routine which called the 113.Fn setjmp 114routines returns. 115.Pp 116All accessible objects have values as of the time 117.Fn longjmp 118routine was called, except that the values of objects of automatic storage 119invocation duration that do not have the 120.Vt volatile 121type and have been changed between the 122.Fn setjmp 123invocation and 124.Fn longjmp 125call are indeterminate. 126.Pp 127The 128.Fn setjmp Ns / Ns Fn longjmp 129pairs save and restore the signal mask while 130.Fn _setjmp Ns / Ns Fn _longjmp 131pairs save and restore only the register set and the stack. 132(See 133.Fn sigprocmask 2 . ) 134.Pp 135The 136.Fn sigsetjmp Ns / Ns Fn siglongjmp 137function 138pairs save and restore the signal mask if the argument 139.Fa savemask 140is non-zero, otherwise only the register set and the stack are saved. 141.Sh ERRORS 142If the contents of the 143.Fa env 144are corrupted, or correspond to an environment that has already returned, 145the 146.Fn longjmp 147routine calls the routine 148.Fn longjmperror 3 . 149If 150.Fn longjmperror 151returns the program is aborted (see 152.Xr abort 3 ) . 153The default version of 154.Fn longjmperror 155prints the message 156.Dq Li longjmp botch 157to standard error and returns. 158User programs wishing to exit more gracefully should write their own 159versions of 160.Fn longjmperror . 161.Sh SEE ALSO 162.Xr sigaction 2 , 163.Xr sigaltstack 2 , 164.Xr signal 3 165.Sh STANDARDS 166The 167.Fn setjmp 168and 169.Fn longjmp 170functions conform to 171.St -isoC . 172The 173.Fn sigsetjmp 174and 175.Fn siglongjmp 176functions conform to 177.St -p1003.1-88 . 178