-
Notifications
You must be signed in to change notification settings - Fork 0
/
rt_sigreturn.html
183 lines (145 loc) · 6.14 KB
/
rt_sigreturn.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!-- Creator : groff version 1.22.4 -->
<!-- CreationDate: Wed Jan 29 11:26:09 2020 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title>SIGRETURN</title>
</head>
<body>
<h1 align="center">SIGRETURN</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#RETURN VALUE">RETURN VALUE</a><br>
<a href="#CONFORMING TO">CONFORMING TO</a><br>
<a href="#NOTES">NOTES</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<a href="#COLOPHON">COLOPHON</a><br>
<hr>
<h2>NAME
<a name="NAME"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">sigreturn,
rt_sigreturn - return from signal handler and cleanup stack
frame</p>
<h2>SYNOPSIS
<a name="SYNOPSIS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>int
sigreturn(...);</b></p>
<h2>DESCRIPTION
<a name="DESCRIPTION"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">If the Linux
kernel determines that an unblocked signal is pending for a
process, then, at the next transition back to user mode in
that process (e.g., upon return from a system call or when
the process is rescheduled onto the CPU), it creates a new
frame on the user-space stack where it saves various pieces
of process context (processor status word, registers, signal
mask, and signal stack settings).</p>
<p style="margin-left:11%; margin-top: 1em">The kernel also
arranges that, during the transition back to user mode, the
signal handler is called, and that, upon return from the
handler, control passes to a piece of user-space code
commonly called the "signal trampoline". The
signal trampoline code in turn calls <b>sigreturn</b>().</p>
<p style="margin-left:11%; margin-top: 1em">This
<b>sigreturn</b>() call undoes everything that was
done—changing the process’s signal mask,
switching signal stacks (see <b>sigaltstack</b>(2))—in
order to invoke the signal handler. Using the information
that was earlier saved on the user-space stack
<b>sigreturn</b>() restores the process’s signal mask,
switches stacks, and restores the process’s context
(processor flags and registers, including the stack pointer
and instruction pointer), so that the process resumes
execution at the point where it was interrupted by the
signal.</p>
<h2>RETURN VALUE
<a name="RETURN VALUE"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>sigreturn</b>()
never returns.</p>
<h2>CONFORMING TO
<a name="CONFORMING TO"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Many UNIX-type
systems have a <b>sigreturn</b>() system call or near
equivalent. However, this call is not specified in POSIX,
and details of its behavior vary across systems.</p>
<h2>NOTES
<a name="NOTES"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>sigreturn</b>()
exists only to allow the implementation of signal handlers.
It should <b>never</b> be called directly. (Indeed, a simple
<b>sigreturn</b>() wrapper in the GNU C library simply
returns -1, with <i>errno</i> set to <b>ENOSYS</b>.) Details
of the arguments (if any) passed to <b>sigreturn</b>() vary
depending on the architecture. (On some architectures, such
as x86-64, <b>sigreturn</b>() takes no arguments, since all
of the information that it requires is available in the
stack frame that was previously created by the kernel on the
user-space stack.)</p>
<p style="margin-left:11%; margin-top: 1em">Once upon a
time, UNIX systems placed the signal trampoline code onto
the user stack. Nowadays, pages of the user stack are
protected so as to disallow code execution. Thus, on
contemporary Linux systems, depending on the architecture,
the signal trampoline code lives either in the
<b>vdso</b>(7) or in the C library. In the latter case, the
C library’s <b>sigaction</b>(2) wrapper function
informs the kernel of the location of the trampoline code by
placing its address in the <i>sa_restorer</i> field of the
<i>sigaction</i> structure, and sets the <b>SA_RESTORER</b>
flag in the <i>sa_flags</i> field.</p>
<p style="margin-left:11%; margin-top: 1em">The saved
process context information is placed in a <i>ucontext_t</i>
structure (see <i><sys/ucontext.h></i>). That
structure is visible within the signal handler as the third
argument of a handler established via <b>sigaction</b>(2)
with the <b>SA_SIGINFO</b> flag.</p>
<p style="margin-left:11%; margin-top: 1em">On some other
UNIX systems, the operation of the signal trampoline differs
a little. In particular, on some systems, upon transitioning
back to user mode, the kernel passes control to the
trampoline (rather than the signal handler), and the
trampoline code calls the signal handler (and then calls
<b>sigreturn</b>() once the handler returns).</p>
<p style="margin-left:11%; margin-top: 1em"><b>C
library/kernel differences</b> <br>
The original Linux system call was named <b>sigreturn</b>().
However, with the addition of real-time signals in Linux
2.2, a new system call, <b>rt_sigreturn</b>() was added to
support an enlarged <i>sigset_t</i> type. The GNU C library
hides these details from us, transparently employing
<b>rt_sigreturn</b>() when the kernel provides it.</p>
<h2>SEE ALSO
<a name="SEE ALSO"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>kill</b>(2),
<b>restart_syscall</b>(2), <b>sigaltstack</b>(2),
<b>signal</b>(2), <b>getcontext</b>(3), <b>signal</b>(7),
<b>vdso</b>(7)</p>
<h2>COLOPHON
<a name="COLOPHON"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">This page is
part of release 5.02 of the Linux <i>man-pages</i> project.
A description of the project, information about reporting
bugs, and the latest version of this page, can be found at
https://www.kernel.org/doc/man-pages/.</p>
<hr>
</body>
</html>