Commit | Line | Data |
---|---|---|
ae59e04c | 1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. |
cc866634 | 2 | .\" All rights reserved. |
c7eaf808 | 3 | .\" |
043368e6 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the American National Standards Committee X3, on Information | |
6 | .\" Processing Systems. | |
7 | .\" | |
cc866634 KB |
8 | .\" %sccs.include.redist.man% |
9 | .\" | |
dc971c33 | 10 | .\" @(#)setjmp.3 6.10 (Berkeley) %G% |
c7eaf808 | 11 | .\" |
ae59e04c CL |
12 | .Dd |
13 | .Dt SETJMP 3 | |
14 | .Os BSD 4 | |
15 | .Sh NAME | |
16 | .Nm sigsetjmp , | |
17 | .Nm siglongjmp , | |
18 | .Nm setjmp , | |
19 | .Nm longjmp , | |
20 | .Nm _setjmp , | |
21 | .Nm _longjmp longjmperror | |
22 | .Nd non-local jumps | |
23 | .Sh SYNOPSIS | |
24 | .Fd #include <setjmp.h> | |
25 | .Ft int | |
26 | .Fn sigsetjmp "sigjmp_buf env" "int savemask" | |
27 | .Ft void | |
28 | .Fn siglongjmp "sigjmp_buf env" "int val" | |
29 | .Ft int | |
30 | .Fn setjmp "jmp_buf env" | |
31 | .Ft void | |
32 | .Fn longjmp "jmp_buf env" "int val" | |
33 | .Ft int | |
34 | .Fn _setjmp "jmp_buf env" | |
35 | .Ft void | |
36 | .Fn _longjmp "jmp_buf env" "int val" | |
37 | .Ft void | |
38 | .Fn longjmperror void | |
39 | .Sh DESCRIPTION | |
cc866634 | 40 | The |
ae59e04c CL |
41 | .Fn sigsetjmp , |
42 | .Fn setjmp , | |
cc866634 | 43 | and |
ae59e04c | 44 | .Fn _setjmp |
cc866634 | 45 | functions save their calling environment in |
ae59e04c | 46 | .Fa env . |
cc866634 | 47 | Each of these functions returns 0. |
ae59e04c | 48 | .Pp |
bdb37901 | 49 | The corresponding |
ae59e04c CL |
50 | .Fn longjmp |
51 | functions restore the environment saved by their most recent respective | |
52 | invocations | |
cc866634 | 53 | of the |
ae59e04c | 54 | .Fn setjmp |
cc866634 | 55 | function. |
ae59e04c CL |
56 | They then return so that program execution continues as if the corresponding |
57 | invocation of the | |
58 | .Fn setjmp | |
59 | call had just returned the value specified by | |
60 | .Fa val , | |
cc866634 | 61 | instead of 0. |
ae59e04c | 62 | .Pp |
bdb37901 | 63 | Pairs of calls may be intermixed, i.e. both |
ae59e04c | 64 | .Fn sigsetjmp |
cc866634 | 65 | and |
ae59e04c | 66 | .Fn siglongjmp |
cc866634 | 67 | and |
ae59e04c | 68 | .Fn setjmp |
cc866634 | 69 | and |
ae59e04c | 70 | .Fn longjmp |
cc866634 | 71 | combinations may be used in the same program, however, individual |
dc971c33 | 72 | calls may not, e.g. the |
ae59e04c | 73 | .Fa env |
bdb37901 | 74 | argument to |
dc971c33 | 75 | .Fn setjmp |
cc866634 | 76 | may not be passed to |
dc971c33 | 77 | .Fn siglongjmp . |
ae59e04c | 78 | .Pp |
cc866634 | 79 | The |
ae59e04c | 80 | .Fn longjmp |
cc866634 | 81 | routines may not be called after the routine which called the |
ae59e04c | 82 | .Fn setjmp |
cc866634 | 83 | routines returns. |
ae59e04c CL |
84 | .Pp |
85 | All accessible objects have values as of the time | |
86 | .Fn longjmp | |
87 | routine was called, except that the values of objects of automatic storage | |
88 | invocation duration that do not have the | |
89 | .Em volatile | |
90 | type and have been changed between the | |
91 | .Fn setjmp | |
92 | invocation and | |
93 | .Fn longjmp | |
94 | call are indeterminate. | |
95 | .Pp | |
96 | The | |
bdb37901 | 97 | .Fn setjmp Ns / Ns Fn longjmp |
ae59e04c | 98 | pairs save and restore the signal mask while |
bdb37901 | 99 | .Fn _setjmp Ns / Ns Fn _longjmp |
cc866634 | 100 | pairs save and restore only the register set and the stack. |
bdb37901 | 101 | (See |
ae59e04c CL |
102 | .Fn sigmask 2 . ) |
103 | .Pp | |
104 | The | |
bdb37901 | 105 | .Fn sigsetjmp Ns / Ns Fn siglongjmp |
ae59e04c | 106 | function |
cc866634 | 107 | pairs save and restore the signal mask if the argument |
ae59e04c | 108 | .Fa savemask |
cc866634 | 109 | is non-zero, otherwise only the register set and the stack are saved. |
ae59e04c | 110 | .Sh ERRORS |
93a6fb6f | 111 | If the contents of the |
ae59e04c | 112 | .Fa env |
93a6fb6f | 113 | are corrupted, or correspond to an environment that has already returned, |
bdb37901 | 114 | the |
ae59e04c | 115 | .Fn longjmp |
cc866634 | 116 | routine calls the routine |
ae59e04c | 117 | .Fn longjmperror 3 . |
93a6fb6f | 118 | If |
ae59e04c CL |
119 | .Fn longjmperror |
120 | returns the program is aborted (see | |
121 | .Xr abort 2 ) . | |
bdb37901 | 122 | The default version of |
ae59e04c CL |
123 | .Fn longjmperror |
124 | prints the message | |
125 | .Dq Li longjmp botch | |
126 | to standard error and returns. | |
cc866634 | 127 | User programs wishing to exit more gracefully should write their own |
bdb37901 | 128 | versions of |
ae59e04c CL |
129 | .Fn longjmperror . |
130 | .Sh SEE ALSO | |
131 | .Xr sigaction 2 , | |
bce5def7 | 132 | .Xr sigaltstack 2 , |
ae59e04c | 133 | .Xr signal 3 |
d5001484 CL |
134 | .Sh STANDARDS |
135 | The | |
136 | .Fn setjmp | |
137 | and | |
138 | .Fn longjmp | |
139 | functions conform to | |
140 | .St -ansiC . | |
dc971c33 KB |
141 | The |
142 | .Fn sigsetjmp | |
143 | and | |
144 | .Fn siglongjmp | |
145 | functions conform to | |
146 | .St -p1003.1-88 . |