]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/setjmp.3
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3 / setjmp.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, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Added sigsetjmp, Sun Mar 2 22:03:05 EST 1997, jrv@vanzandt.mv.com
24 .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu
25 .\" "
26 .TH SETJMP 3 1997-03-02 "" "Library functions"
27 .SH NAME
28 setjmp, sigsetjmp \- save stack context for non-local goto
29 .SH SYNOPSIS
30 .ad l
31 .B #include <setjmp.h>
32 .sp
33 .nf
34 .BI "int setjmp(jmp_buf " env );
35 .BI "int sigsetjmp(sigjmp_buf " env ", int " savesigs );
36 .fi
37 .ad b
38 .SH DESCRIPTION
39 \fBsetjmp()\fP and \fBlongjmp()\fP are useful for dealing with errors
40 and interrupts encountered in a low-level subroutine of a program.
41 \fBsetjmp()\fP saves the stack context/environment in \fIenv\fP for
42 later use by \fBlongjmp()\fP. The stack context will be invalidated
43 if the function which called \fBsetjmp()\fP returns.
44 .P
45 \fBsigsetjmp()\fP is similar to \fBsetjmp()\fP. If \fIsavesigs\fP is nonzero,
46 the set of blocked signals is saved in \fIenv\fP and will be restored
47 if a \fBsiglongjmp()\fP is later performed with this \fIenv\fP.
48 .SH "RETURN VALUE"
49 \fBsetjmp()\fP and \fBsigsetjmp()\fP return 0 if returning directly, and
50 non-zero when returning from \fBlongjmp()\fP using the saved context.
51 .SH "CONFORMING TO"
52 POSIX, ISO 9899 (C99)
53 .SH NOTES
54 POSIX does not specify whether \fBsetjmp\fP will save the
55 signal context. (In SYSV it will not. In BSD4.3 it will, and there
56 is a function \fB_setjmp\fP that will not.)
57 If you want to save signal masks, use \fBsigsetjmp\fP.
58 .P
59 \fBsetjmp()\fP and \fBsigsetjmp\fP make programs hard to understand
60 and maintain. If possible an alternative should be used.
61 .SH "SEE ALSO"
62 .BR longjmp (3),
63 .BR siglongjmp (3)