1LONGJMP(3P)                POSIX Programmer's Manual               LONGJMP(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       longjmp — non-local goto
14

SYNOPSIS

16       #include <setjmp.h>
17
18       void longjmp(jmp_buf env, int val);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
24       defers to the ISO C standard.
25
26       The  longjmp() function shall restore the environment saved by the most
27       recent invocation of setjmp() in the same process, with the correspond‐
28       ing  jmp_buf  argument.  If the most recent invocation of setjmp() with
29       the corresponding jmp_buf occurred in another thread, or if there is no
30       such  invocation,  or  if  the  function  containing  the invocation of
31       setjmp() has terminated execution in the interim, or if the  invocation
32       of  setjmp()  was within the scope of an identifier with variably modi‐
33       fied type and execution has left that scope in the interim, the  behav‐
34       ior  is  undefined.   It  is unspecified whether longjmp() restores the
35       signal mask, leaves the signal mask unchanged, or restores  it  to  its
36       value at the time setjmp() was called.
37
38       All  accessible  objects  have  values, and all other components of the
39       abstract machine have state (for example, floating-point  status  flags
40       and  open  files), as of the time longjmp() was called, except that the
41       values of objects of automatic storage duration are unspecified if they
42       meet all the following conditions:
43
44        *  They  are  local  to  the  function  containing  the  corresponding
45           setjmp() invocation.
46
47        *  They do not have volatile-qualified type.
48
49        *  They are changed between  the  setjmp()  invocation  and  longjmp()
50           call.
51
52       As it bypasses the usual function call and return mechanisms, longjmp()
53       shall execute correctly in contexts of interrupts, signals, and any  of
54       their  associated  functions.  However,  if longjmp() is invoked from a
55       nested signal handler (that is, from a function invoked as a result  of
56       a signal raised during the handling of another signal), the behavior is
57       undefined.
58
59       The effect of a call to longjmp() where initialization of  the  jmp_buf
60       structure was not performed in the calling thread is undefined.
61

RETURN VALUE

63       After  longjmp()  is  completed,  program execution continues as if the
64       corresponding invocation of setjmp() had just returned the value speci‐
65       fied by val.  The longjmp() function shall not cause setjmp() to return
66       0; if val is 0, setjmp() shall return 1.
67

ERRORS

69       No errors are defined.
70
71       The following sections are informative.
72

EXAMPLES

74       None.
75

APPLICATION USAGE

77       Applications whose behavior depends on the value  of  the  signal  mask
78       should not use longjmp() and setjmp(), since their effect on the signal
79       mask is unspecified,  but  should  instead  use  the  siglongjmp()  and
80       sigsetjmp() functions (which can save and restore the signal mask under
81       application control).
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       setjmp(), sigaction(), siglongjmp(), sigsetjmp()
91
92       The Base Definitions volume of POSIX.1‐2008, <setjmp.h>
93
95       Portions of this text are reprinted and reproduced in  electronic  form
96       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
97       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
98       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
99       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
100       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
101       event of any discrepancy between this version and the original IEEE and
102       The  Open Group Standard, the original IEEE and The Open Group Standard
103       is the referee document. The original Standard can be  obtained  online
104       at http://www.unix.org/online.html .
105
106       Any  typographical  or  formatting  errors that appear in this page are
107       most likely to have been introduced during the conversion of the source
108       files  to  man page format. To report such errors, see https://www.ker
109       nel.org/doc/man-pages/reporting_bugs.html .
110
111
112
113IEEE/The Open Group                  2013                          LONGJMP(3P)
Impressum