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