SETJMP(3) BSD Programmer's Manual SETJMP(3)NAME
setjmp, longjmp, _setjmp, _longjmp, sigsetjmp, siglongjmp - non-local
jumps
SYNOPSIS
#include <setjmp.h>
int
setjmp(jmp_buf env);
void
longjmp(jmp_buf env, int val);
int
_setjmp(jmp_buf env);
void
_longjmp(jmp_buf env, int val);
int
sigsetjmp(sigjmp_buf env, int savemask);
void
siglongjmp(sigjmp_buf env, int val);
DESCRIPTION
The setjmp() function saves information about its calling environment in
env, and returns 0.
The longjmp() function restores the environment saved by the last call to
setjmp() with env as an argument. It then returns so that program execu-
tion continues as if the setjmp() invocation had returned val, instead of
0. The longjmp() function may not specify a return value of 0. If
longjmp() is called with a val of 0, program execution will continue as
if the setjmp() invocation had returned 1.
All accessible objects have values as of the time the longjmp() routine
was called, except that the values of objects of automatic storage invo-
cation duration, that do not have the volatile type and have been changed
between the setjmp() invocation and longjmp() call, are indeterminate.
The setjmp()/longjmp() routines save and restore the signal mask. (See
sigprocmask(2).)
Calling the longjmp() routine after the routine which called setjmp() re-
turns will result in undefined behavior.
The _setjmp()/_longjmp() routines are identical to setjmp()/longjmp(),
except that they do not save and restore the signal mask.
The sigsetjmp()/siglongjmp() routines are identical to setjmp()/longjmp()
if the argument savemask is non-zero, otherwise they are identical to
_setjmp()/_longjmp().
Pairs of calls may be intermixed, e.g., both setjmp()/longjmp() and
sigsetjmp()/siglongjmp() pairs may be used in the same program. Individ-
ual calls should not be intermixed, e.g. the env argument to setjmp() may
not be passed to siglongjmp().
ERRORS
If the longjmp() routines detect that the contents of env are corrupted,
or correspond to an environment that has already returned, longjmp() will
call abort(2). There is no guarantee such corruption or misuse will be
detected.
SEE ALSOsigprocmask(2)STANDARDS
The setjmp() and longjmp() functions conform to ANSI C X3.159-1989
(``ANSI C ''). The sigsetjmp() and siglongjmp() functions conform to IEEE
Std1003.1-1988 (``POSIX'').
4th Berkeley Distribution June 4, 1993 2