SETJMP(3C) DOMAIN/IX Reference Manual (SYS5) SETJMP(3C)
NAME
setjmp, longjmp - non-local goto
USAGE
#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 pro-
gram.
Setjmp saves its stack environment in env (whose type,
jmpbuf, is defined in the <setjmp.h> header file) for later
use by longjmp. It returns the value zero.
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 zero. If
longjmp is invoked with a second argument of zero, setjmp
will return 1. All accessible data had values as of the
time longjmp was called.
NOTES
If env was never primed by a call to setjmp, or if the last
such call was in a function which has since returned, and
you call longjmp, unexpected results are likely.
RELATED INFORMATION
signal(2)
Printed 5/10/85 SETJMP-1