4.3BSD-Reno/src/lib/libc/gen/setjmp.3

Compare this file to the similar file:
Show the results in this format:

.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms are permitted
.\" provided that: (1) source distributions retain this entire copyright
.\" notice and comment, and (2) distributions including binaries display
.\" the following acknowledgement:  ``This product includes software
.\" developed by the University of California, Berkeley and its contributors''
.\" in the documentation or other materials provided with the distribution
.\" and in all advertising materials mentioning features or use of this
.\" software. Neither the name of the University nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.\"	@(#)setjmp.3	6.4 (Berkeley) 5/27/90
.\"
.TH SETJMP 3 "May 27, 1990"
.UC 4
.SH NAME
sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp longjmperror \-
non-local jumps
.SH SYNOPSIS
.nf
.ft B
#include <setjmp.h>

sigsetjmp(sigjmp_buf env, int savemask);

void
siglongjmp(sigjmp_buf env, int val);

setjmp(jmp_buf env);

void
longjmp(jmp_buf env, int val);

_setjmp(jmp_buf env);

void
_longjmp(jmp_buf env, int val);

void
longjmperror();
.ft R
.fi
.SH DESCRIPTION
The
.IR sigsetjmp ,
.IR setjmp ,
and
.IR _setjmp
functions save their calling environment in
.IR env . 
Each of these functions returns 0.
.PP
The corresponding 
.I longjmp
functions restore the environment saved by their respective versions
of the
.I setjmp
function.
They then return so that program execution continues as if the
.I setjmp
call had returned 
.IR val ,
instead of 0.
.PP
Pairs of calls may be intermixed, i.e. both 
.I sigsetjmp
and
.I siglongjmp
and
.I setjmp
and
.I longjmp
combinations may be used in the same program, however, individual
calls may not, i.e. the 
.I env
argument to 
.I sigsetjmp
may not be passed to
.IR longjmp .
.PP
The
.I longjmp
routines may not be called after the routine which called the
.I setjmp
routines returns.
.PP
All accessible data have values as of the time the
.I longjmp
routine was called.
.PP
.I Setjmp/longjmp
pairs save and restore the signal mask (see 
.IR sigmask (2)),
while
.I _setjmp/_longjmp
pairs save and restore only the register set and the stack.
.PP
.I Sigsetjmp/siglongjmp
pairs save and restore the signal mask if the argument
.I savemask
is non-zero, otherwise only the register set and the stack are saved.
.SH ERRORS
If the contents of the
.I env
are corrupted, or correspond to an environment that has already returned,
the 
.I longjmp
routine calls the routine
.IR longjmperror (3).
If
.I longjmperror
returns the program is aborted (see abort(2)).
The default version of 
.I longjmperror
prints the message ``longjmp botch'' to standard error and returns.
User programs wishing to exit more gracefully should write their own
versions of 
.IR longjmperror .
.SH "SEE ALSO"
sigvec(2), sigstack(2), signal(3)