]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/longjmp.3
getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid...
[thirdparty/man-pages.git] / man3 / longjmp.3
1 .\" Written by Michael Haardt, Fri Nov 25 14:51:42 MET 1994
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, see
20 .\" <http://www.gnu.org/licenses/>.
21 .\"
22 .\" Added siglongjmp, Sun Mar 2 22:03:05 EST 1997, jrv@vanzandt.mv.com
23 .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu
24 .\" "
25 .TH LONGJMP 3 2009-01-13 "" "Linux Programmer's Manual"
26 .SH NAME
27 longjmp, siglongjmp \- nonlocal jump to a saved stack context
28 .SH SYNOPSIS
29 .nf
30 .B #include <setjmp.h>
31
32 .BI "void longjmp(jmp_buf " env ", int " val );
33
34 .BI "void siglongjmp(sigjmp_buf " env ", int " val );
35 .fi
36 .sp
37 .in -4n
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .in
41 .sp
42 .BR siglongjmp ():
43 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
44 .SH DESCRIPTION
45 .BR longjmp ()
46 and
47 .BR setjmp (3)
48 are useful for dealing with errors
49 and interrupts encountered in a low-level subroutine of a program.
50 .BR longjmp ()
51 restores the environment saved by the last call of
52 .BR setjmp (3)
53 with the corresponding \fIenv\fP argument.
54 After
55 .BR longjmp ()
56 is completed, program execution continues as if the
57 corresponding call of
58 .BR setjmp (3)
59 had just returned the value
60 \fIval\fP.
61 .BR longjmp ()
62 cannot cause 0 to be returned.
63 If
64 .BR longjmp ()
65 is invoked with a second argument of 0, 1 will be returned instead.
66 .P
67 .BR siglongjmp ()
68 is similar to
69 .BR longjmp ()
70 except for the type of
71 its \fIenv\fP argument.
72 If, and only if, the
73 .BR sigsetjmp (3)
74 call that set this
75 \fIenv\fP used a nonzero \fIsavesigs\fP flag,
76 .BR siglongjmp ()
77 also restores the signal mask that was saved by
78 .BR sigsetjmp (3).
79 .SH RETURN VALUE
80 These functions never return.
81 .SH CONFORMING TO
82 C89, C99, and POSIX.1-2001 specify
83 .BR longjmp ().
84 POSIX.1-2001 specifies
85 .BR siglongjmp ().
86 .SH NOTES
87 POSIX does not specify whether
88 .BR longjmp ()
89 will restore the signal context (see
90 .BR setjmp (3)
91 for some more details).
92 If you want to portably save and restore signal masks, use
93 .BR sigsetjmp (3)
94 and
95 .BR siglongjmp ().
96 .P
97 The values of automatic variables are unspecified after a call to
98 .BR longjmp ()
99 if they meet all the following criteria:
100 .IP \(bu 3
101 they are local to the function that made the corresponding
102 .BR setjmp (3)
103 call;
104 .IP \(bu
105 their values are changed between the calls to
106 .BR setjmp (3)
107 and
108 .BR longjmp ();
109 and
110 .IP \(bu
111 they are not declared as
112 .IR volatile .
113 .P
114 Analogous remarks apply for
115 .BR siglongjmp ().
116 .P
117 .BR longjmp ()
118 and
119 .BR siglongjmp ()
120 make programs hard to
121 understand and maintain.
122 If possible an alternative should be used.
123 .SH SEE ALSO
124 .BR setjmp (3),
125 .BR sigsetjmp (3)