#include <setjmp.h> void longjmp(jmp_buf env, int code);
longjmp
returns control to an ancestor routine, passing the value
of the integer code
. The point of return is determined by the
contents of env
, which should be initialized by a call to
setjmp
in the target routine. Note that if the value of
code
is 0, the value returned to the target is 1.
longjmp
.
longjmp
does not change the program's signal mask. Use
sigsetjmp
to save the signal mask, and siglongjmp
to
restore the signal mask to the mask in effect when sigsetjmp
was called.
setjmp
has terminated), a user ABEND 1204 is issued. If an invalid
env
is not detected, serious (and unpredictable) problems occur.
If you attempt to terminate a routine in a language other than C, a user ABEND 1224 is issued. See Appendix 5, "Using the INDep Option for Interlanguage Communication," in the SAS/C Compiler and Library User's Guide, Fourth Edition for more information.
#include <stdio.h> #include <setjmp.h> #include <stdlib.h> jmp_buf env; main() { int ret; if ((ret = setjmp(env)) != 0) { fprintf(stderr, "longjmp called with value %dn", ret); exit(1); } dummy(); fprintf(stderr, "longjmp was not called.n"); } void dummy(void) { puts("Entering dummy routine."); longjmp(env, 3); puts("Never reached."); }
blkjmp
, setjmp
, siglongjmp
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.