setjmp(3C) setjmp(3C)
NAME
setjmp, longjmp - non-local goto
SYNOPSIS
#include <setjmp.h>
int setjmp (env)
jmpbuf env;
void longjmp (env, val)
jmpbuf env;
int val;
DESCRIPTION
These functions are useful for dealing with errors and
interrupts encountered in a low-level subroutine of a
program.
setjmp saves its stack environment in env for later use by
longjmp. The environment type jmpbuf is defined in the
<setjmp.h> header file. setjmp returns the value 0.
longjmp restores the environment saved by the last call of
setjmp with the corresponding env argument. After longjmp
is completed, program execution continues as if the
corresponding call of setjmp (which must not itself have
returned in the interim) had just returned the value val.
longjmp cannot cause setjmp to return the value 0. If
longjmp is invoked with a second argument of 0, setjmp will
return 1. All accessible data have values as of the time
longjmp was called.
SEE ALSO
signal(3).
WARNING
longjmp fails if it is called when env was never primed by a
call to setjmp or when the last such call is in a function
which has since returned.
Page 1 (last mod. 1/14/87)