OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / sigaltstack.2
1 '\" t
2 .\" Copyright (c) 2001, Michael Kerrisk (mtk.manpages@gmail.com)
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" aeb, various minor fixes
25 .\"
26 .\" Japanese Version Copyright (c) 2001 Yuichi SATO
27 .\"         all rights reserved.
28 .\" Translated 2001-11-04, Yuichi SATO <ysato@h4.dion.ne.jp>
29 .\" Updated 2001-12-09, Yuichi SATO
30 .\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\" Updated 2006-01-04, Akihiro MOTOKI, Catch up to LDP 2.20
32 .\"
33 .\"WORD:        alternate signal stack  ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯
34 .\"WORD:        establish       (¥¹¥¿¥Ã¥¯¤Î) ³ÎΩ
35 .\"
36 .TH SIGALTSTACK 2 2008-10-04 "Linux" "Linux Programmer's Manual"
37 .\"O .SH NAME
38 .SH Ì¾Á°
39 .\"O sigaltstack \- set and/or get signal stack context
40 sigaltstack \- ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î¥³¥ó¥Æ¥­¥¹¥È¤òÀßÄꡦ¼èÆÀ¤¹¤ë
41 .\"O .SH SYNOPSIS
42 .SH ½ñ¼°
43 .B #include <signal.h>
44 .sp
45 .BI "int sigaltstack(const stack_t *" ss ", stack_t *" oss );
46 .sp
47 .in -4n
48 .\"O Feature Test Macro Requirements for glibc (see
49 .\"O .BR feature_test_macros (7)):
50 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
51 .RB ( feature_test_macros (7)
52 »²¾È):
53 .in
54 .sp
55 .BR sigaltstack ():
56 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
57 .\" .br
58 .\" .BR sigstack ():
59 .\" _BSD_SOURCE || _XOPEN_SOURCE >= 500
60 .\"O .SH DESCRIPTION
61 .SH ÀâÌÀ
62 .\"O .BR sigaltstack ()
63 .\"O allows a process to define a new alternate
64 .\"O signal stack and/or retrieve the state of an existing
65 .\"O alternate signal stack.
66 .\"O An alternate signal stack is used during the
67 .\"O execution of a signal handler if the establishment of that handler (see
68 .\"O .BR sigaction (2))
69 .\"O requested it.
70 .BR sigaltstack ()
71 ¤ò»È¤¦¤È¡¢
72 ¥×¥í¥»¥¹¤Ï¿·¤·¤¤ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤òÄêµÁ¤·¤¿¤ê¡¢
73 ´û¸¤ÎÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î¾õÂÖ¤ò¼èÆÀ¤Ç¤­¤ë¡£
74 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤òÍ׵᤹¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
75 .RB ( sigaction (2)
76 »²¾È)¡¢¥Ï¥ó¥É¥é¤Î¼Â¹ÔÃæ¤Ï¤½¤Î¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤¬»È¤ï¤ì¤ë¡£
77
78 .\"O The normal sequence of events for using an alternate signal stack
79 .\"O is the following:
80 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò»È¤¦ºÝ¤Î°ìÈÌŪ¤Ê¼ê½ç¤Ï¡¢°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë:
81 .TP 3
82 1.
83 .\"O Allocate an area of memory to be used for the alternate
84 .\"O signal stack.
85 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Ç»È¤¦¥á¥â¥êÎΰè¤ò³ÎÊݤ¹¤ë¡£
86 .TP
87 2.
88 .\"O Use
89 .\"O .BR sigaltstack ()
90 .\"O to inform the system of the existence and
91 .\"O location of the alternate signal stack.
92 .BR sigaltstack ()
93 ¤ò»È¤Ã¤Æ¡¢
94 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î¸ºß¤È¾ì½ê¤ò¥·¥¹¥Æ¥à¤ËÃΤ餻¤ë¡£
95 .TP
96 3.
97 .\"O When establishing a signal handler using
98 .\"O .BR sigaction (2),
99 .\"O inform the system that the signal handler should be executed
100 .\"O on the alternate signal stack by
101 .\"O specifying the \fBSA_ONSTACK\fP flag.
102 .BR sigaction (2)
103 ¤ò»È¤Ã¤Æ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò³ÎΩ¤¹¤ëºÝ¡¢
104 \fBSA_ONSTACK\fP ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤Ë¤è¤ê¡¢
105 ¤½¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤òÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤ò
106 ¥·¥¹¥Æ¥à¤ËÃΤ餻¤ë¡£
107 .P
108 .\"O The \fIss\fP argument is used to specify a new
109 .\"O alternate signal stack, while the \fIoss\fP argument
110 .\"O is used to retrieve information about the currently
111 .\"O established signal stack.
112 \fIss\fP °ú¤­¿ô¤Ï¡¢¿·¤·¤¤¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»È¤¦¡£
113 ¤Þ¤¿ \fIoss\fP °ú¤­¿ô¤Ï¡¢¸½ºß³ÎΩ¤µ¤ì¤Æ¤¤¤ë
114 ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë»È¤¦¡£
115 .\"O If we are interested in performing just one
116 .\"O of these tasks then the other argument can be specified as NULL.
117 .\"O Each of these arguments is a structure of the following type:
118 ¤³¤ÎÁàºî¤Î¤¦¤Á 1 ¤Ä¤À¤±¤ò¼Â¹Ô¤µ¤»¤ë¤Ë¤Ï¡¢
119 »ÈÍѤ·¤Ê¤¤°ú¤­¿ô¤ò NULL ¤Ë»ØÄꤹ¤ì¤Ð¤è¤¤¡£
120 °ú¤­¿ô¤È¤Ê¤ë¹½Â¤ÂΤϡ¢°Ê²¼¤Î¤è¤¦¤Ê·¿¤Ç¤¢¤ë:
121 .sp
122 .in +4n
123 .nf
124 typedef struct {
125 .\"O     void  *ss_sp;     /* Base address of stack */
126     void  *ss_sp;     /* ¥¹¥¿¥Ã¥¯¤Î¥Ù¡¼¥¹¥¢¥É¥ì¥¹ */
127 .\"O     int    ss_flags;  /* Flags */
128     int    ss_flags;  /* ¥Õ¥é¥° */
129 .\"O     size_t ss_size;   /* Number of bytes in stack */
130     size_t ss_size;   /* ¥¹¥¿¥Ã¥¯¤Î¥Ð¥¤¥È¿ô */
131 } stack_t;
132 .fi
133 .in
134
135 .\"O To establish a new alternate signal stack,
136 .\"O \fIss.ss_flags\fP is set to zero, and \fIss.ss_sp\fP and
137 .\"O \fIss.ss_size\fP specify the starting address and size of
138 .\"O the stack.
139 ¿·µ¬¤ÎÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò³ÎΩ¤¹¤ë¤Ë¤Ï¡¢
140 \fIss.ss_flags\fP ¤ò 0 ¤ËÀßÄꤷ¡¢
141 \fIss.ss_sp\fP ¤È \fIss.ss_size\fP ¤Ë
142 ¥¹¥¿¥Ã¥¯¤Î³«»Ï¥¢¥É¥ì¥¹¤È¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤ò»ØÄꤹ¤ë¡£
143 .\"O The constant \fBSIGSTKSZ\fP is defined to be large enough
144 .\"O to cover the usual size requirements for an alternate signal stack,
145 .\"O and the constant \fBMINSIGSTKSZ\fP defines the minimum
146 .\"O size required to execute a signal handler.
147 Äê¿ô \fBSIGSTKSZ\fP ¤Ï¡¢ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤¬Ä̾ïɬÍפ¹¤ë
148 ¥µ¥¤¥º¤è¤ê¤â½¼Ê¬Â礭¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
149 ¤Þ¤¿Äê¿ô \fBMINSIGSTKSZ\fP ¤Ï¡¢
150 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Î¼Â¹Ô¤ËɬÍפʺǾ®¥µ¥¤¥º¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
151
152 .\"O When a signal handler is invoked on the alternate stack,
153 .\"O the kernel automatically aligns the address given in \fIss.ss_sp\fP
154 .\"O to a suitable address boundary for the underlying hardware architecture.
155 ÂåÂØ¥¹¥¿¥Ã¥¯¤Ç¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
156 ¥«¡¼¥Í¥ë¤Ë¤è¤ê¼«Æ°Åª¤Ë¡¢\fIss.ss_sp\fP ¤Ç»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹¤Ï
157 Æ°ºî¤·¤Æ¤¤¤ë¥Ï¡¼¥É¥¦¥§¥¢¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤ËŬ¤·¤¿¥¢¥É¥ì¥¹¶­³¦¤Ë
158 Ä´À°¤µ¤ì¤ë¡£
159
160 .\"O To disable an existing stack, specify \fIss.ss_flags\fP
161 .\"O as \fBSS_DISABLE\fP.
162 .\"O In this case, the remaining fields
163 .\"O in \fIss\fP are ignored.
164 ´û¸¤Î¥¹¥¿¥Ã¥¯¤ò̵¸ú¤Ë¤¹¤ë¤Ë¤Ï¡¢
165 \fIss.ss_flags\fP ¤ò \fBSS_DISABLE\fP ¤Ë»ØÄꤹ¤ë¡£
166 ¤³¤Î¾ì¹ç¡¢\fIss\fP ¤Î¾¤Î¥Õ¥£¡¼¥ë¥É¤Ï̵»ë¤µ¤ì¤ë¡£
167
168 .\"O If \fIoss\fP is not NULL, then it is used to return information about
169 .\"O the alternate signal stack which was in effect prior to the
170 .\"O call to
171 .\"O .BR sigaltstack ().
172 \fIoss\fP ¤¬ NULL °Ê³°¤Î¾ì¹ç¡¢
173 \fIoss\fP ¤ËÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î¾ðÊó¤¬ÊÖ¤µ¤ì¤ë¡£
174 ¤³¤ì¤Ï (¼Â¼ÁŪ¤Ë)
175 .BR sigaltstack ()
176 ¤Î¸Æ¤Ó½Ð¤·¤è¤êÀè¤Ë¹Ô¤ï¤ì¤ë¡£
177 .\"O The \fIoss.ss_sp\fP and \fIoss.ss_size\fP fields return the starting
178 .\"O address and size of that stack.
179 .\"O The \fIoss.ss_flags\fP may return either of the following values:
180 \fIoss.ss_sp\fP ¤È \fIoss.ss_size\fP ¥Õ¥£¡¼¥ë¥É¤Ë
181 ¥¹¥¿¥Ã¥¯¤Î³«»Ï¥¢¥É¥ì¥¹¤È¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤¬ÊÖ¤µ¤ì¤ë¡£
182 \fIoss.ss_flags\fP ¤Ë¤Ï°Ê²¼¤Î¤É¤Á¤é¤«¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë:
183 .TP
184 .B SS_ONSTACK
185 .\"O The process is currently executing on the alternate signal stack.
186 .\"O (Note that it is not possible
187 .\"O to change the alternate signal stack if the process is
188 .\"O currently executing on it.)
189 ¥×¥í¥»¥¹¤¬ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë
190 (¥×¥í¥»¥¹¤¬´û¤Ë¤½¤Î¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢
191 ¤½¤ì¤ÈƱ¤¸¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Ë¤ÏÊѹ¹¤Ç¤­¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È)¡£
192 .TP
193 .B SS_DISABLE
194 .\"O The alternate signal stack is currently disabled.
195 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤¬¸½ºß̵¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
196 .\"O .SH "RETURN VALUE"
197 .SH ÊÖ¤êÃÍ
198 .\"O .BR sigaltstack ()
199 .\"O returns 0 on success, or \-1 on failure with
200 .\"O \fIerrno\fP set to indicate the error.
201 .BR sigaltstack ()
202 ¤ÏÀ®¸ù¤·¤¿¾ì¹ç 0 ¤òÊÖ¤¹¡£
203 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¤Æ¡¢
204 ¥¨¥é¡¼¤ò¼¨¤¹Ãͤˠ\fIerrno\fP ¤òÀßÄꤹ¤ë¡£
205 .\"O .SH ERRORS
206 .SH ¥¨¥é¡¼
207 .TP
208 .B EFAULT
209 .\"O Either \fIss\fP or \fIoss\fP is not NULL and points to an area
210 .\"O outside of the process's address space.
211 \fIss\fP ¤Þ¤¿¤Ï \fIoss\fP ¤Î¤É¤Á¤é¤¬¡¢NULL °Ê³°¤Ç¡¢
212 ¤«¤Ä¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤Î³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
213 .TP
214 .B EINVAL
215 .\"O \fIss\fP is not NULL and the \fIss_flags\fP field contains
216 .\"O a nonzero value other than
217 .\"O .BR SS_DISABLE .
218 \fIss\fP ¤¬ NULL °Ê³°¤Ç¡¢\fIss_flags\fP ¥Õ¥£¡¼¥ë¥É¤¬
219 .B SS_DISABLE
220 °Ê³°¤Î 0 ¤Ç¤Ê¤¤ÃͤˤʤäƤ¤¤ë¡£
221 .TP
222 .B ENOMEM
223 .\"O The specified size of the new alternate signal stack
224 .\"O (\fIss.ss_size\fP) was less than \fBMINSTKSZ\fP.
225 ¿·¤·¤¤ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯ (\fIss.ss_size\fP) ¤Ë»ØÄꤷ¤¿¥µ¥¤¥º¤¬
226 \fBMINSTKSZ\fP ¤è¤ê¾®¤µ¤¤¡£
227 .TP
228 .B EPERM
229 .\"O An attempt was made to change the alternate signal stack while
230 .\"O it was active (i.e., the process was already executing
231 .\"O on the current alternate signal stack).
232 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤¬Í­¸ú¤Ç¤¢¤ë¤È¤­¤ËÊѹ¹¤ò¹Ô¤ª¤¦¤È¤·¤¿
233 (¤Ä¤Þ¤ê¡¢¥×¥í¥»¥¹¤¬´û¤Ë¸½ºß¤ÎÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤¿)¡£
234 .\"O .SH "CONFORMING TO"
235 .SH ½àµò
236 SUSv2, SVr4, POSIX.1-2001.
237 .\"O .SH NOTES
238 .SH Ãí°Õ
239 .\"O The most common usage of an alternate signal stack is to handle the
240 .\"O .B SIGSEGV
241 .\"O signal that is generated if the space available for the
242 .\"O normal process stack is exhausted: in this case, a signal handler for
243 .\"O .B SIGSEGV
244 .\"O cannot be invoked on the process stack; if we wish to handle it,
245 .\"O we must use an alternate signal stack.
246 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò»ÈÍѤ¹¤ëºÇ¤â¤è¤¯¤¢¤ë¾ìÌ̤ϡ¢
247 .B SIGSEGV
248 ¥·¥°¥Ê¥ë¤ò°·¤¦¤È¤­¤Ç¤¢¤ë¡£
249 .B SIGSEGV
250 ¤Ï¥×¥í¥»¥¹¤ÎÄ̾ï¤Î¥¹¥¿¥Ã¥¯¤¬ÍøÍѤǤ­¤ë¶õ´Ö¤¬»È¤¤²Ì¤¿¤µ¤ì¤¿ºÝ¤Ë
251 À¸À®¤µ¤ì¤ë¥·¥°¥Ê¥ë¤Ç¤¢¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢
252 .B SIGSEGV
253 ÍѤΥ·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¾å¤Ç¤Ïµ¯Æ°¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
254 ¤½¤Î¤¿¤á¡¢¤³¤Î¥·¥°¥Ê¥ë¤ò°·¤ª¤¦¤È¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢
255 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò»ÈÍѤ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
256 .P
257 .\"O Establishing an alternate signal stack is useful if a process
258 .\"O expects that it may exhaust its standard stack.
259 ¥×¥í¥»¥¹¤¬É¸½à¤Î¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò»È¤¤²Ì¤¿¤¹¤³¤È¤¬Í½ÁÛ¤µ¤ì¤ë¾ì¹ç¤Ï¡¢
260 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò³ÎΩ¤¹¤ë¤ÈÊØÍø¤Ç¤¢¤ë¡£
261 .\"O This may occur, for example, because the stack grows so large
262 .\"O that it encounters the upwardly growing heap, or it reaches a
263 .\"O limit established by a call to \fBsetrlimit(RLIMIT_STACK, &rlim)\fP.
264 Î㤨¤Ð¡¢¥¹¥¿¥Ã¥¯¤¬ºÇ¾å°Ì¥¢¥É¥ì¥¹¤«¤é
265 ²¼°Ì¥¢¥É¥ì¥¹Êý¸þ¤ËÈó¾ï¤Ë¤¿¤¯¤µ¤óÀѤޤì¤Æ¤·¤Þ¤¦¤³¤È¤Ç¡¢
266 ºÇ²¼°Ì¥¢¥É¥ì¥¹¤«¤é¾å°Ì¥¢¥É¥ì¥¹Êý¸þ¤ËÀѤޤì¤ë¥Ò¡¼¥×¤È¤Ö¤Ä¤«¤Ã¤Æ¤·¤Þ¤¦¾ì¹ç¤ä¡¢
267 \fBsetrlimit(RLIMIT_STACK, &rlim)\fP ¤Î¸Æ¤Ó½Ð¤·¤Ç³ÎΩ¤µ¤ì¤¿
268 À©¸Â¤Ë㤷¤Æ¤·¤Þ¤Ã¤¿¾ì¹ç¤Ë¡¢¤³¤ÎÍͤʻö¤¬µ¯¤³¤ë¡£
269 .\"O If the standard stack is exhausted, the kernel sends
270 .\"O the process a \fBSIGSEGV\fP signal.
271 .\"O In these circumstances the only way to catch this signal is
272 .\"O on an alternate signal stack.
273 ɸ½à¤Î¥¹¥¿¥Ã¥¯¤ò»È¤¤²Ì¤¿¤·¤Æ¤·¤Þ¤¦¤È¡¢
274 ¥«¡¼¥Í¥ë¤Ï¥×¥í¥»¥¹¤Ë \fBSIGSEGV\fP ¥·¥°¥Ê¥ë¤òÁ÷¤ë¡£
275 ¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ç¤Ï¡¢ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¤·¤«¥·¥°¥Ê¥ë¤ò¥­¥ã¥Ã¥Á¤Ç¤­¤Ê¤¤¡£
276 .P
277 .\"O On most hardware architectures supported by Linux, stacks grow
278 .\"O downwards.
279 .\"O .BR sigaltstack ()
280 .\"O automatically takes account
281 .\"O of the direction of stack growth.
282 Linux ¤¬¥µ¥Ý¡¼¥È¤¹¤ë¿¤¯¤Î¥Ï¡¼¥É¥¦¥§¥¢¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢
283 ¥¹¥¿¥Ã¥¯¤Ï²¼°Ì¥¢¥É¥ì¥¹Êý¸þ¤ËÀѤޤì¤ë¡£
284 .BR sigaltstack ()
285 ¤Ï¥¹¥¿¥Ã¥¯¤¬ÀѤޤì¤ëÊý¸þ¤ò¼«Æ°Åª¤Ë·èÄꤹ¤ë¡£
286 .P
287 .\"O Functions called from a signal handler executing on an alternate
288 .\"O signal stack will also use the alternate signal stack.
289 .\"O (This also applies to any handlers invoked for other signals while
290 .\"O the process is executing on the alternate signal stack.)
291 .\"O Unlike the standard stack, the system does not
292 .\"O automatically extend the alternate signal stack.
293 .\"O Exceeding the allocated size of the alternate signal stack will
294 .\"O lead to unpredictable results.
295 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë
296 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤«¤é¸Æ¤Ð¤ì¤ë´Ø¿ô¤â¡¢ÂåÂØ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò»È¤¦
297 (¥×¥í¥»¥¹¤¬ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¾å¤Ç¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
298 ¾¤Î¥·¥°¥Ê¥ë¤Ç¸Æ¤Ó½Ð¤µ¤ì¤ë¥Ï¥ó¥É¥é¤â¤³¤ÎÂåÂØ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò»È¤¦)¡£
299 ɸ½à¤Î¥¹¥¿¥Ã¥¯¤È¤Ï°Û¤Ê¤ê¡¢
300 ¥·¥¹¥Æ¥à¤ÏÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤ò¼«Æ°Åª¤Ë³ÈÄ¥¤·¤Ê¤¤¡£
301 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯ÍѤ˳ÎÊݤ·¤¿¥µ¥¤¥º¤ò±Û¤¨¤¿¾ì¹ç¡¢
302 ·ë²Ì¤ÏͽÁۤǤ­¤Ê¤¤¡£
303 .P
304 .\"O A successful call to
305 .\"O .BR execve (2)
306 .\"O removes any existing alternate
307 .\"O signal stack.
308 .\"O A child process created via
309 .\"O .BR fork ()
310 .\"O inherits a copy of its parent's alternate signal stack settings.
311 .BR execve (2)
312 ¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤¹¤ë¤È¡¢
313 ´û¸¤ÎÁ´¤Æ¤ÎÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤¬ºï½ü¤µ¤ì¤ë¡£
314 .BR fork ()
315 ·Ðͳ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢¿Æ¥×¥í¥»¥¹¤ÎÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Î
316 ÀßÄê¤Î¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£
317 .P
318 .\"O .BR sigaltstack ()
319 .\"O supersedes the older
320 .\"O .BR sigstack ()
321 .\"O call.
322 .\"O For backwards compatibility, glibc also provides
323 .\"O .BR sigstack ().
324 .\"O All new applications should be written using
325 .\"O .BR sigaltstack ().
326 .BR sigaltstack ()
327 ¤Ï°ÊÁ°¤Î
328 .BR sigstack ()
329 ¤òÃÖ¤­´¹¤¨¤ë¤â¤Î¤Ç¤¢¤ë¡£
330 ²áµî¥×¥í¥°¥é¥à¤È¤Î¸ß´¹À­¤Î¤¿¤á¡¢glibc ¤Ç¤Ï
331 .BR sigstack ()
332 ¤âÄ󶡤·¤Æ¤¤¤ë¡£
333 ¿·¤·¤¤¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÏÁ´¤Æ
334 .BR sigaltstack ()
335 ¤ò»È¤Ã¤Æ½ñ¤¯¤Ù¤­¤Ç¤¢¤ë¡£
336 .\"O .SS History
337 .SS Îò»Ë
338 .\"O 4.2BSD had a
339 .\"O .BR sigstack ()
340 .\"O system call.
341 .\"O It used a slightly
342 .\"O different struct, and had the major disadvantage that the caller
343 .\"O had to know the direction of stack growth.
344 4.2BSD ¤Ë¤Ï
345 .BR sigstack ()
346 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¤¢¤Ã¤¿¡£
347 ¤³¤Î´Ø¿ô¤Ï¾¯¤·°Û¤Ê¤Ã¤¿¹½Â¤ÂΤò»È¤Ã¤Æ¤ª¤ê¡¢
348 ¸Æ¤Ó½Ð¤·¤¿Â¦¤¬¥¹¥¿¥Ã¥¯¤ÎÀѤޤì¤ëÊý¸þ¤òÃΤäƤ¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤È¤¤¤¦
349 Â礭¤Ê·çÅÀ¤¬¤¢¤Ã¤¿¡£
350 .\"O .SH EXAMPLE
351 .SH Îã
352 .\"O The following code segment demonstrates the use of
353 .\"O .BR sigaltstack ():
354 °Ê²¼¤Î¥³¡¼¥É¤Ç
355 .BR sigaltstack ()
356 ¤Î»ÈÍÑË¡¤Î°ìÉô¤ò¼¨¤¹:
357
358 .in +4n
359 .nf
360 stack_t ss;
361
362 ss.ss_sp = malloc(SIGSTKSZ);
363 if (ss.ss_sp == NULL)
364 .\"O     /* Handle error */;
365     /* ¥Ï¥ó¥É¥ë¥¨¥é¡¼ */;
366 ss.ss_size = SIGSTKSZ;
367 ss.ss_flags = 0;
368 if (sigaltstack(&ss, NULL) == \-1)
369 .\"O     /* Handle error */;
370     /* ¥Ï¥ó¥É¥ë¥¨¥é¡¼ */;
371 .fi
372 .in
373 .\"O .SH "SEE ALSO"
374 .SH ´ØÏ¢¹àÌÜ
375 .BR execve (2),
376 .BR setrlimit (2),
377 .BR sigaction (2),
378 .BR siglongjmp (3),
379 .BR sigsetjmp (3),
380 .BR signal (7)