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

NAME

6       longjmp - non-local goto
7

SYNOPSIS

9       #include <setjmp.h>
10
11       void longjmp(jmp_buf env, int val);
12
13

DESCRIPTION

15       The  longjmp() function shall restore the environment saved by the most
16       recent invocation of setjmp() in the same thread, with the  correspond‐
17       ing  jmp_buf  argument. If there is no such invocation, or if the func‐
18       tion containing the invocation of setjmp() has terminated execution  in
19       the  interim,  or if the invocation of setjmp() was within the scope of
20       an identifier with variably modified type and execution has  left  that
21       scope  in  the  interim, the behavior is undefined.   It is unspecified
22       whether longjmp() restores the signal  mask,  leaves  the  signal  mask
23       unchanged, or restores it to its value at the time setjmp() was called.
24
25       All  accessible  objects  have  values, and all other components of the
26       abstract machine have state (for example, floating-point  status  flags
27       and  open  files), as of the time longjmp() was called, except that the
28       values of objects of automatic storage duration are unspecified if they
29       meet all the following conditions:
30
31        * They are local to the function containing the corresponding setjmp()
32          invocation.
33
34        * They do not have volatile-qualified type.
35
36        * They are changed between the setjmp() invocation and longjmp() call.
37
38       As it bypasses the usual function call and return mechanisms, longjmp()
39       shall  execute correctly in contexts of interrupts, signals, and any of
40       their associated functions. However, if longjmp()  is  invoked  from  a
41       nested  signal handler (that is, from a function invoked as a result of
42       a signal raised during the handling of another signal), the behavior is
43       undefined.
44
45       The  effect  of a call to longjmp() where initialization of the jmp_buf
46       structure was not performed in the calling thread is undefined.
47

RETURN VALUE

49       After longjmp() is completed, program execution  continues  as  if  the
50       corresponding invocation of setjmp() had just returned the value speci‐
51       fied by val. The longjmp() function shall not cause setjmp() to  return
52       0; if val is 0, setjmp() shall return 1.
53

ERRORS

55       No errors are defined.
56
57       The following sections are informative.
58

EXAMPLES

60       None.
61

APPLICATION USAGE

63       Applications  whose  behavior  depends  on the value of the signal mask
64       should not use longjmp() and setjmp(), since their effect on the signal
65       mask  is  unspecified,  but  should  instead  use  the siglongjmp() and
66       sigsetjmp() functions (which can save and restore the signal mask under
67       application control).
68

RATIONALE

70       None.
71

FUTURE DIRECTIONS

73       None.
74

SEE ALSO

76       setjmp()  , sigaction() , siglongjmp() , sigsetjmp() , the Base Defini‐
77       tions volume of IEEE Std 1003.1-2001, <setjmp.h>
78
80       Portions of this text are reprinted and reproduced in  electronic  form
81       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
82       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
83       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
84       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
85       event of any discrepancy between this version and the original IEEE and
86       The Open Group Standard, the original IEEE and The Open Group  Standard
87       is  the  referee document. The original Standard can be obtained online
88       at http://www.opengroup.org/unix/online.html .
89
90
91
92IEEE/The Open Group                  2003                           LONGJMP(P)
Impressum