date and time created 91/04/12 13:40:37 by bostic
[unix-history] / usr / src / lib / libc / gen / setjmp.3
CommitLineData
cc866634
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
c7eaf808 3.\"
cc866634
KB
4.\" %sccs.include.redist.man%
5.\"
c9410998 6.\" @(#)setjmp.3 6.4 (Berkeley) %G%
c7eaf808 7.\"
d6f93ed6 8.TH SETJMP 3 ""
c7eaf808
KM
9.UC 4
10.SH NAME
c9410998 11sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp longjmperror \-
cc866634 12non-local jumps
c7eaf808
KM
13.SH SYNOPSIS
14.nf
cc866634
KB
15.ft B
16#include <setjmp.h>
17
18sigsetjmp(sigjmp_buf env, int savemask);
19
20void
21siglongjmp(sigjmp_buf env, int val);
22
23setjmp(jmp_buf env);
24
25void
26longjmp(jmp_buf env, int val);
27
28_setjmp(jmp_buf env);
29
30void
31_longjmp(jmp_buf env, int val);
c9410998
KB
32
33void
34longjmperror();
cc866634 35.ft R
c7eaf808
KM
36.fi
37.SH DESCRIPTION
cc866634
KB
38The
39.IR sigsetjmp ,
40.IR setjmp ,
41and
42.IR _setjmp
43functions save their calling environment in
44.IR env .
45Each of these functions returns 0.
c7eaf808 46.PP
cc866634
KB
47The corresponding
48.I longjmp
49functions restore the environment saved by their respective versions
50of the
51.I setjmp
52function.
53They then return so that program execution continues as if the
54.I setjmp
55call had returned
56.IR val ,
57instead of 0.
c7eaf808 58.PP
cc866634
KB
59Pairs of calls may be intermixed, i.e. both
60.I sigsetjmp
61and
62.I siglongjmp
63and
c7eaf808 64.I setjmp
cc866634 65and
c7eaf808 66.I longjmp
cc866634
KB
67combinations may be used in the same program, however, individual
68calls may not, i.e. the
69.I env
70argument to
71.I sigsetjmp
72may not be passed to
73.IR longjmp .
e04f0ee2 74.PP
cc866634
KB
75The
76.I longjmp
77routines may not be called after the routine which called the
78.I setjmp
79routines returns.
80.PP
81All accessible data have values as of the time the
e04f0ee2 82.I longjmp
cc866634
KB
83routine was called.
84.PP
85.I Setjmp/longjmp
86pairs save and restore the signal mask (see
87.IR sigmask (2)),
e04f0ee2 88while
cc866634
KB
89.I _setjmp/_longjmp
90pairs save and restore only the register set and the stack.
93a6fb6f 91.PP
cc866634
KB
92.I Sigsetjmp/siglongjmp
93pairs save and restore the signal mask if the argument
94.I savemask
95is non-zero, otherwise only the register set and the stack are saved.
96.SH ERRORS
93a6fb6f 97If the contents of the
cc866634 98.I env
93a6fb6f 99are corrupted, or correspond to an environment that has already returned,
cc866634 100the
93a6fb6f 101.I longjmp
cc866634
KB
102routine calls the routine
103.IR longjmperror (3).
93a6fb6f
KM
104If
105.I longjmperror
cc866634 106returns the program is aborted (see abort(2)).
93a6fb6f
KM
107The default version of
108.I longjmperror
109prints the message ``longjmp botch'' to standard error and returns.
cc866634 110User programs wishing to exit more gracefully should write their own
93a6fb6f
KM
111versions of
112.IR longjmperror .
c7eaf808 113.SH "SEE ALSO"
e04f0ee2 114sigvec(2), sigstack(2), signal(3)