]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Written by Michael Haardt, Fri Nov 25 14:51:42 MET 1994 |
2 | .\" | |
1dd72f9c | 3 | .\" %%%LICENSE_START(GPLv2+_DOC_FULL) |
fea681da MK |
4 | .\" This is free documentation; you can redistribute it and/or |
5 | .\" modify it under the terms of the GNU General Public License as | |
6 | .\" published by the Free Software Foundation; either version 2 of | |
7 | .\" the License, or (at your option) any later version. | |
8 | .\" | |
9 | .\" The GNU General Public License's references to "object code" | |
10 | .\" and "executables" are to be interpreted as the output of any | |
11 | .\" document formatting or typesetting system, including | |
12 | .\" intermediate and printed output. | |
13 | .\" | |
14 | .\" This manual is distributed in the hope that it will be useful, | |
15 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | .\" GNU General Public License for more details. | |
18 | .\" | |
19 | .\" You should have received a copy of the GNU General Public | |
c715f741 MK |
20 | .\" License along with this manual; if not, see |
21 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 22 | .\" %%%LICENSE_END |
fea681da MK |
23 | .\" |
24 | .\" Added siglongjmp, Sun Mar 2 22:03:05 EST 1997, jrv@vanzandt.mv.com | |
25 | .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu | |
26 | .\" " | |
460495ca | 27 | .TH LONGJMP 3 2015-08-08 "" "Linux Programmer's Manual" |
fea681da | 28 | .SH NAME |
24b74457 | 29 | longjmp, siglongjmp \- nonlocal jump to a saved stack context |
fea681da | 30 | .SH SYNOPSIS |
fea681da | 31 | .nf |
a45ebabf MK |
32 | .B #include <setjmp.h> |
33 | ||
fea681da | 34 | .BI "void longjmp(jmp_buf " env ", int " val ); |
5895e7eb | 35 | |
fea681da MK |
36 | .BI "void siglongjmp(sigjmp_buf " env ", int " val ); |
37 | .fi | |
cc4615cc MK |
38 | .sp |
39 | .in -4n | |
40 | Feature Test Macro Requirements for glibc (see | |
41 | .BR feature_test_macros (7)): | |
42 | .in | |
43 | .sp | |
44 | .BR siglongjmp (): | |
0f200f07 | 45 | _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE |
fea681da | 46 | .SH DESCRIPTION |
60a90ecd MK |
47 | .BR longjmp () |
48 | and | |
49 | .BR setjmp (3) | |
50 | are useful for dealing with errors | |
fea681da | 51 | and interrupts encountered in a low-level subroutine of a program. |
60a90ecd MK |
52 | .BR longjmp () |
53 | restores the environment saved by the last call of | |
54 | .BR setjmp (3) | |
c6fa0841 MK |
55 | with the corresponding |
56 | .I env | |
57 | argument. | |
c13182ef | 58 | After |
60a90ecd MK |
59 | .BR longjmp () |
60 | is completed, program execution continues as if the | |
61 | corresponding call of | |
62 | .BR setjmp (3) | |
63 | had just returned the value | |
c6fa0841 | 64 | .IR val . |
60a90ecd MK |
65 | .BR longjmp () |
66 | cannot cause 0 to be returned. | |
67 | If | |
68 | .BR longjmp () | |
fea681da MK |
69 | is invoked with a second argument of 0, 1 will be returned instead. |
70 | .P | |
60a90ecd MK |
71 | .BR siglongjmp () |
72 | is similar to | |
73 | .BR longjmp () | |
74 | except for the type of | |
c6fa0841 MK |
75 | its |
76 | .I env | |
77 | argument. | |
78604af5 | 78 | If, and only if, the |
60a90ecd MK |
79 | .BR sigsetjmp (3) |
80 | call that set this | |
c6fa0841 MK |
81 | .I env |
82 | used a nonzero | |
83 | .I savesigs | |
84 | flag, | |
60a90ecd | 85 | .BR siglongjmp () |
1192ed94 MK |
86 | also restores the signal mask that was saved by |
87 | .BR sigsetjmp (3). | |
47297adb | 88 | .SH RETURN VALUE |
fea681da | 89 | These functions never return. |
4ae638ed ZL |
90 | .SH ATTRIBUTES |
91 | For an explanation of the terms used in this section, see | |
92 | .BR attributes (7). | |
93 | .TS | |
94 | allbox; | |
95 | lbw23 lb lb | |
96 | l l l. | |
97 | Interface Attribute Value | |
98 | T{ | |
99 | .BR longjmp (), | |
100 | .BR siglongjmp () | |
101 | T} Thread safety MT-Safe | |
102 | .TE | |
103 | ||
47297adb | 104 | .SH CONFORMING TO |
c898b7ef MK |
105 | .BR longjmp (): |
106 | POSIX.1-2001, POSIX.1-2008, C89, C99. | |
107 | ||
108 | .BR siglongjmp (): | |
109 | POSIX.1-2001, POSIX.1-2008. | |
fea681da | 110 | .SH NOTES |
60a90ecd MK |
111 | POSIX does not specify whether |
112 | .BR longjmp () | |
1192ed94 MK |
113 | will restore the signal context (see |
114 | .BR setjmp (3) | |
dbb433dc | 115 | for some more details). |
1192ed94 | 116 | If you want to portably save and restore signal masks, use |
01b844cc | 117 | .BR sigsetjmp (3) |
1192ed94 | 118 | and |
60a90ecd | 119 | .BR siglongjmp (). |
fea681da | 120 | .P |
305d65e1 MK |
121 | The values of automatic variables are unspecified after a call to |
122 | .BR longjmp () | |
123 | if they meet all the following criteria: | |
124 | .IP \(bu 3 | |
125 | they are local to the function that made the corresponding | |
3c712482 | 126 | .BR setjmp (3) |
305d65e1 MK |
127 | call; |
128 | .IP \(bu | |
129 | their values are changed between the calls to | |
3c712482 | 130 | .BR setjmp (3) |
305d65e1 MK |
131 | and |
132 | .BR longjmp (); | |
133 | and | |
134 | .IP \(bu | |
135 | they are not declared as | |
136 | .IR volatile . | |
137 | .P | |
138 | Analogous remarks apply for | |
139 | .BR siglongjmp (). | |
140 | .P | |
60a90ecd MK |
141 | .BR longjmp () |
142 | and | |
143 | .BR siglongjmp () | |
144 | make programs hard to | |
c13182ef | 145 | understand and maintain. |
6186a355 | 146 | If possible, an alternative should be used. |
47297adb | 147 | .SH SEE ALSO |
fea681da MK |
148 | .BR setjmp (3), |
149 | .BR sigsetjmp (3) |