1LONGJMP(3) Library functions LONGJMP(3)
2
3
4
6 longjmp, siglongjmp - non-local jump to a saved stack context
7
9 #include <setjmp.h>
10
11 void longjmp(jmp_buf env, int val);
12 void siglongjmp(sigjmp_buf env, int val);
13
15 longjmp() and setjmp() are useful for dealing with errors and inter‐
16 rupts encountered in a low-level subroutine of a program. longjmp()
17 restores the environment saved by the last call of setjmp() with the
18 corresponding env argument. After longjmp() is completed, program exe‐
19 cution continues as if the corresponding call of setjmp() had just
20 returned the value val. longjmp() cannot cause 0 to be returned. If
21 longjmp is invoked with a second argument of 0, 1 will be returned
22 instead.
23
24 siglongjmp() is similar to longjmp() except for the type of its env
25 argument. If the sigsetjmp() call that set this env used a non-zero
26 savesigs flag, siglongjmp() also restores the set of blocked signals.
27
29 These functions never return.
30
32 C89, C99, and POSIX.1-2001 specify longjmp(). POSIX.1-2001 specifies
33 siglongjmp().
34
36 POSIX does not specify whether longjmp() will restore the signal con‐
37 text. If you want to save and restore signal masks, use siglongjmp().
38
39 longjmp() and siglongjmp() make programs hard to understand and main‐
40 tain. If possible an alternative should be used.
41
43 setjmp(3), sigsetjmp(3)
44
45
46
47 1997-03-02 LONGJMP(3)