Commit | Line | Data |
---|---|---|
c7eaf808 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
93a6fb6f | 5 | .\" @(#)setjmp.3 6.2 (Berkeley) %G% |
c7eaf808 | 6 | .\" |
d6f93ed6 | 7 | .TH SETJMP 3 "" |
c7eaf808 KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | setjmp, longjmp \- non-local goto | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .B #include <setjmp.h> | |
14 | .PP | |
15 | .B setjmp(env) | |
16 | .B jmp_buf env; | |
17 | .PP | |
18 | .B longjmp(env, val) | |
19 | .B jmp_buf env; | |
e04f0ee2 KM |
20 | .PP |
21 | .B _setjmp(env) | |
22 | .B jmp_buf env; | |
23 | .PP | |
24 | .B _longjmp(env, val) | |
25 | .B jmp_buf env; | |
c7eaf808 KM |
26 | .fi |
27 | .SH DESCRIPTION | |
28 | These routines are useful for dealing with errors | |
29 | and interrupts encountered in | |
30 | a low-level subroutine of a program. | |
31 | .PP | |
32 | .I Setjmp | |
33 | saves its stack environment in | |
34 | .I env | |
35 | for later use by | |
36 | .I longjmp. | |
37 | It returns value 0. | |
38 | .PP | |
39 | .I Longjmp | |
40 | restores the environment saved by the last call of | |
41 | .IR setjmp . | |
42 | It then returns in such a way that execution | |
43 | continues as if the call of | |
44 | .I setjmp | |
45 | had just returned the value | |
46 | .I val | |
47 | to the function that invoked | |
48 | .I setjmp, | |
49 | which must not itself have returned in the interim. | |
50 | All accessible data have values as of the time | |
51 | .I longjmp | |
52 | was called. | |
e04f0ee2 KM |
53 | .PP |
54 | .I Setjmp | |
55 | and | |
56 | .I longjmp | |
57 | save and restore the signal mask | |
58 | .IR sigmask (2), | |
59 | while | |
60 | .I _setjmp | |
61 | and | |
62 | .I _longjmp | |
63 | manipulate only the C stack and registers. | |
93a6fb6f KM |
64 | .SH ERRORS |
65 | .PP | |
66 | If the contents of the | |
67 | .B jmp_buf | |
68 | are corrupted, or correspond to an environment that has already returned, | |
69 | .I longjmp | |
70 | calls the routine | |
71 | .IR longjmperror . | |
72 | If | |
73 | .I longjmperror | |
74 | returns the program is aborted. | |
75 | The default version of | |
76 | .I longjmperror | |
77 | prints the message ``longjmp botch'' to standard error and returns. | |
78 | User programs wishing to exit more gracefully can write their own | |
79 | versions of | |
80 | .IR longjmperror . | |
c7eaf808 | 81 | .SH "SEE ALSO" |
e04f0ee2 | 82 | sigvec(2), sigstack(2), signal(3) |