SETJMP(S) XENIX System V SETJMP(S)
Name
setjmp, longjmp - Performs a nonlocal ``goto''.
Syntax
#include <setjmp.h>
int setjmp (env)
jmp_buf env;
void longjmp (env, val)
jmp_buf env;
int val;
Description
These routines 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. It returns a value of 0.
longjmp restores the environment saved by the last call of
setjmp. It then returns in such a way that execution
continues as if the call of setjmp had just returned the
value val to the corresponding call to setjmp. The routine
which calls setjmp must not itself have returned in the
interim. longjmp cannot return a value of 0. If longjmp is
invoked with a second argument of 0, it will return a value
of 1. All accessible data have values as of the time
longjmp was called. The only exception to this is register
variables. The value of register variables is undefined in
the routine that called setjmp when the corresponding
longjmp is invoked.
See Also
signal(S)
Warning
If longjmp is called even though env was never primed by a
call to setjmp, or when the last such call was in a function
which has since returned, absolute chaos is guaranteed.
Page 1 (printed 8/7/87)