]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/longjmp.3
ldd.1, sprof.1, accept.2, alarm.2, bind.2, chdir.2, clock_nanosleep.2, close.2, conne...
[thirdparty/man-pages.git] / man3 / longjmp.3
CommitLineData
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 29longjmp, 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
40Feature 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 ()
48and
49.BR setjmp (3)
50are useful for dealing with errors
fea681da 51and interrupts encountered in a low-level subroutine of a program.
60a90ecd
MK
52.BR longjmp ()
53restores the environment saved by the last call of
54.BR setjmp (3)
c6fa0841
MK
55with the corresponding
56.I env
57argument.
c13182ef 58After
60a90ecd
MK
59.BR longjmp ()
60is completed, program execution continues as if the
61corresponding call of
62.BR setjmp (3)
63had just returned the value
c6fa0841 64.IR val .
60a90ecd
MK
65.BR longjmp ()
66cannot cause 0 to be returned.
67If
68.BR longjmp ()
fea681da
MK
69is invoked with a second argument of 0, 1 will be returned instead.
70.P
60a90ecd
MK
71.BR siglongjmp ()
72is similar to
73.BR longjmp ()
74except for the type of
c6fa0841
MK
75its
76.I env
77argument.
78604af5 78If, and only if, the
60a90ecd
MK
79.BR sigsetjmp (3)
80call that set this
c6fa0841
MK
81.I env
82used a nonzero
83.I savesigs
84flag,
60a90ecd 85.BR siglongjmp ()
1192ed94
MK
86also restores the signal mask that was saved by
87.BR sigsetjmp (3).
47297adb 88.SH RETURN VALUE
fea681da 89These functions never return.
4ae638ed
ZL
90.SH ATTRIBUTES
91For an explanation of the terms used in this section, see
92.BR attributes (7).
93.TS
94allbox;
95lbw23 lb lb
96l l l.
97Interface Attribute Value
98T{
99.BR longjmp (),
100.BR siglongjmp ()
101T} Thread safety MT-Safe
102.TE
103
47297adb 104.SH CONFORMING TO
c898b7ef
MK
105.BR longjmp ():
106POSIX.1-2001, POSIX.1-2008, C89, C99.
107
108.BR siglongjmp ():
109POSIX.1-2001, POSIX.1-2008.
fea681da 110.SH NOTES
60a90ecd
MK
111POSIX does not specify whether
112.BR longjmp ()
1192ed94
MK
113will restore the signal context (see
114.BR setjmp (3)
dbb433dc 115for some more details).
1192ed94 116If you want to portably save and restore signal masks, use
01b844cc 117.BR sigsetjmp (3)
1192ed94 118and
60a90ecd 119.BR siglongjmp ().
fea681da 120.P
305d65e1
MK
121The values of automatic variables are unspecified after a call to
122.BR longjmp ()
123if they meet all the following criteria:
124.IP \(bu 3
125they are local to the function that made the corresponding
3c712482 126.BR setjmp (3)
305d65e1
MK
127call;
128.IP \(bu
129their values are changed between the calls to
3c712482 130.BR setjmp (3)
305d65e1
MK
131and
132.BR longjmp ();
133and
134.IP \(bu
135they are not declared as
136.IR volatile .
137.P
138Analogous remarks apply for
139.BR siglongjmp ().
140.P
60a90ecd
MK
141.BR longjmp ()
142and
143.BR siglongjmp ()
144make programs hard to
c13182ef 145understand and maintain.
6186a355 146If possible, an alternative should be used.
47297adb 147.SH SEE ALSO
fea681da
MK
148.BR setjmp (3),
149.BR sigsetjmp (3)