]>
Commit | Line | Data |
---|---|---|
ada7c492 A |
1 | .\" Copyright (c) 2002 Packet Design, LLC. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Subject to the following obligations and disclaimer of warranty, | |
5 | .\" use and redistribution of this software, in source or object code | |
6 | .\" forms, with or without modifications are expressly permitted by | |
7 | .\" Packet Design; provided, however, that: | |
8 | .\" | |
9 | .\" (i) Any and all reproductions of the source or object code | |
10 | .\" must include the copyright notice above and the following | |
11 | .\" disclaimer of warranties; and | |
12 | .\" (ii) No rights are granted, in any manner or form, to use | |
13 | .\" Packet Design trademarks, including the mark "PACKET DESIGN" | |
14 | .\" on advertising, endorsements, or otherwise except as such | |
15 | .\" appears in the above copyright notice or in the software. | |
16 | .\" | |
17 | .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND | |
18 | .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO | |
19 | .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING | |
20 | .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED | |
21 | .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, | |
22 | .\" OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE, | |
23 | .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS | |
24 | .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, | |
25 | .\" RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE | |
26 | .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE | |
27 | .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT, | |
28 | .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL | |
29 | .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF | |
30 | .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF | |
31 | .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
32 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | |
33 | .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF | |
34 | .\" THE POSSIBILITY OF SUCH DAMAGE. | |
35 | .\" | |
36 | .\" $FreeBSD: src/lib/libc/gen/getcontext.3,v 1.3 2004/12/03 14:10:04 rse Exp $ | |
37 | .\" | |
38 | .Dd September 10, 2002 | |
39 | .Dt GETCONTEXT 3 | |
40 | .Os | |
41 | .Sh NAME | |
42 | .Nm getcontext , setcontext | |
43 | .Nd get and set user thread context | |
44 | .Sh LIBRARY | |
45 | .Lb libc | |
46 | .Sh SYNOPSIS | |
47 | .In ucontext.h | |
48 | .Ft int | |
49 | .Fn getcontext "ucontext_t *ucp" | |
50 | .Ft int | |
51 | .Fn setcontext "const ucontext_t *ucp" | |
52 | .Sh DESCRIPTION | |
53 | The | |
54 | .Fn getcontext | |
55 | function | |
56 | saves the current thread's execution context in the structure pointed to by | |
57 | .Fa ucp . | |
58 | This saved context may then later be restored by calling | |
59 | .Fn setcontext . | |
60 | .Pp | |
61 | The | |
62 | .Fn setcontext | |
63 | function | |
64 | makes a previously saved thread context the current thread context, i.e., | |
65 | the current context is lost and | |
66 | .Fn setcontext | |
67 | does not return. | |
68 | Instead, execution continues in the context specified by | |
69 | .Fa ucp , | |
70 | which must have been previously initialized by a call to | |
71 | .Fn getcontext , | |
72 | .Xr makecontext 3 , | |
73 | or by being passed as an argument to a signal handler (see | |
74 | .Xr sigaction 2 ) . | |
75 | .Pp | |
76 | If | |
77 | .Fa ucp | |
78 | was initialized by | |
79 | .Fn getcontext , | |
80 | then execution continues as if the original | |
81 | .Fn getcontext | |
82 | call had just returned (again). | |
83 | .Pp | |
84 | If | |
85 | .Fa ucp | |
86 | was initialized by | |
87 | .Xr makecontext 3 , | |
88 | execution continues with the invocation of the function specified to | |
89 | .Xr makecontext 3 . | |
90 | When that function returns, | |
91 | .Fa "ucp->uc_link" | |
92 | determines what happens next: | |
93 | if | |
94 | .Fa "ucp->uc_link" | |
95 | is | |
96 | .Dv NULL , | |
97 | the process exits; | |
98 | otherwise, | |
99 | .Fn setcontext "ucp->uc_link" | |
100 | is implicitly invoked. | |
101 | .Pp | |
102 | If | |
103 | .Fa ucp | |
104 | was initialized by the invocation of a signal handler, execution continues | |
105 | at the point the thread was interrupted by the signal. | |
106 | .Sh RETURN VALUES | |
107 | If successful, | |
108 | .Fn getcontext | |
109 | returns zero and | |
110 | .Fn setcontext | |
111 | does not return; otherwise \-1 is returned. | |
112 | .Sh ERRORS | |
113 | No errors are defined for | |
114 | .Fn getcontext | |
115 | or | |
116 | .Fn setcontext . | |
117 | .Sh SEE ALSO | |
118 | .Xr sigaction 2 , | |
119 | .Xr sigaltstack 2 , | |
120 | .Xr makecontext 3 , | |
121 | .Xr ucontext 3 |