1LONGJMP(3)                 Linux Programmer's Manual                LONGJMP(3)
2
3
4

NAME

6       longjmp, siglongjmp - non-local jump to a saved stack context
7

SYNOPSIS

9       #include <setjmp.h>
10
11       void longjmp(jmp_buf env, int val);
12
13       void siglongjmp(sigjmp_buf env, int val);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       siglongjmp(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
18

DESCRIPTION

20       longjmp()  and  setjmp(3) are useful for dealing with errors and inter‐
21       rupts encountered in a low-level subroutine of  a  program.   longjmp()
22       restores  the  environment saved by the last call of setjmp(3) with the
23       corresponding env argument.  After longjmp() is completed, program exe‐
24       cution  continues  as  if  the corresponding call of setjmp(3) had just
25       returned the value val.  longjmp() cannot cause 0 to be  returned.   If
26       longjmp()  is  invoked  with a second argument of 0, 1 will be returned
27       instead.
28
29       siglongjmp() is similar to longjmp() except for the  type  of  its  env
30       argument.   If,  and  only  if, the sigsetjmp(3) call that set this env
31       used a non-zero savesigs flag, siglongjmp() also  restores  the  signal
32       mask that was saved by sigsetjmp(3).
33

RETURN VALUE

35       These functions never return.
36

CONFORMING TO

38       C89,  C99,  and POSIX.1-2001 specify longjmp().  POSIX.1-2001 specifies
39       siglongjmp().
40

NOTES

42       POSIX does not specify whether longjmp() will restore the  signal  con‐
43       text  (see  setjmp(3)  for some more details).  If you want to portably
44       save and restore signal masks, use sigsetjmp() and siglongjmp().
45
46       The values of automatic variables  are  unspecified  after  a  call  to
47       longjmp() if they meet all the following criteria:
48
49       ·  they are local to the function that made the corresponding setjmp(3)
50          call;
51
52       ·  their  values  are  changed  between  the  calls  to  setjmp(3)  and
53          longjmp(); and
54
55       ·  they are not declared as volatile.
56
57       Analogous remarks apply for siglongjmp().
58
59       longjmp()  and  siglongjmp() make programs hard to understand and main‐
60       tain.  If possible an alternative should be used.
61

SEE ALSO

63       setjmp(3), sigsetjmp(3)
64

COLOPHON

66       This page is part of release 3.22 of the Linux  man-pages  project.   A
67       description  of  the project, and information about reporting bugs, can
68       be found at http://www.kernel.org/doc/man-pages/.
69
70
71
72                                  2009-01-13                        LONGJMP(3)
Impressum