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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
'\" t
.\" Copyright (c) 2001, Michael Kerrisk (mtk.manpages@gmail.com)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" aeb, various minor fixes
.\"
.\" Japanese Version Copyright (c) 2001 Yuichi SATO
.\" all rights reserved.
.\" Translated 2001-11-04, Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated 2001-12-09, Yuichi SATO
.\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-01-04, Akihiro MOTOKI, Catch up to LDP 2.20
.\"
.\"WORD: alternate signal stack إʥ륹å
.\"WORD: establish (å) Ω
.\"
.TH SIGALTSTACK 2 2007-07-26 "Linux" "Linux Programmer's Manual"
.SH ̾
sigaltstack \- ʥ륹åΥƥȤꡦ
.SH
.B #include <signal.h>
.sp
.BI "int sigaltstack(const stack_t *" ss ", stack_t *" oss );
.sp
.in -4n
glibc εǽޥ
.RB ( feature_test_macros (7)
):
.in
.sp
.BR sigaltstack ():
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
.\" .br
.\" .BR sigstack ():
.\" _BSD_SOURCE || _XOPEN_SOURCE >= 500
.SH
.BR sigaltstack ()
Ȥȡ
ץϿإʥ륹åꡢ
¸إʥ륹åξ֤Ǥ롣
ʥϥɥ餬إʥ륹å᤹褦ꤵƤ
.RB ( sigaction (2)
)ϥɥμ¹ϤΥʥ륹åȤ롣
إʥ륹åȤݤΰŪʼϡʲ̤Ǥ:
.TP 3
1.
إʥ륹åǻȤΰݤ롣
.TP
2.
.BR sigaltstack ()
Ȥäơ
إʥ륹å¸ߤȾƥΤ餻롣
.TP
3.
.BR sigaction (2)
ȤäƥʥϥɥΩݡ
\fBSA_ONSTACK\fP ե饰ꤹ뤳Ȥˤꡢ
Υʥϥɥإʥ륹åǼ¹Ԥ뤳Ȥ
ƥΤ餻롣
.P
\fIss\fP ϡʥ륹åꤹ뤿˻Ȥ
ޤ \fIoss\fP ϡ߳ΩƤ
ʥ륹åξ뤿˻Ȥ
Τ 1 Ĥ¹Ԥˤϡ
Ѥʤ NULL ˻ꤹФ褤
Ȥʤ빽¤ΤϡʲΤ褦ʷǤ:
.sp
.in +4n
.nf
typedef struct {
void *ss_sp; /* åΥ١ɥ쥹 */
int ss_flags; /* ե饰 */
size_t ss_size; /* åΥХȿ */
} stack_t;
.fi
.in
إʥ륹åΩˤϡ
\fIss.ss_flags\fP 0 ꤷ
\fIss.ss_sp\fP \fIss.ss_size\fP
åγϥɥ쥹ȥåꤹ롣
\fBSIGSTKSZ\fP ϡإʥ륹å̾ɬפ
⽼ʬ礭Ƥ롣
ޤ \fBMINSIGSTKSZ\fP ϡ
ʥϥɥμ¹ԤɬפʺǾƤ롣
إåǥʥϥɥ餬ư줿ˤϡ
ͥˤ꼫ưŪˡ\fIss.ss_sp\fP ǻꤵ줿ɥ쥹
ưƤϡɥƥŬɥ쥹
Ĵ롣
¸Υå̵ˤˤϡ
\fIss.ss_flags\fP \fBSS_DISABLE\fP ˻ꤹ롣
ξ硢\fIss\fP ¾Υեɤ̵뤵롣
\fIoss\fP NULL ʳξ硢
\fIoss\fP إʥ륹åξ֤롣
(¼Ū)
.BR sigaltstack ()
θƤӽФ˹Ԥ롣
\fIoss.ss_sp\fP \fIoss.ss_size\fP եɤ
åγϥɥ쥹ȥå֤롣
\fIoss.ss_flags\fP ˤϰʲΤɤ餫֤ͤ:
.TP
.B SS_ONSTACK
ץإʥ륹åǼ¹ԤƤ
(ץˤΥʥ륹åǼ¹ԤƤϡ
Ʊʥ륹åˤѹǤʤդ뤳)
.TP
.B SS_DISABLE
إʥ륹å̵ˤʤäƤ롣
.SH ֤
.BR sigaltstack ()
0 ֤
Ԥ \-1 ֤ơ
顼ͤ \fIerrno\fP ꤹ롣
.SH 顼
.TP
.B EFAULT
\fIss\fP ޤ \fIoss\fP Τɤ餬NULL ʳǡ
ĥץΥɥ쥹֤γؤƤ롣
.TP
.B EINVAL
\fIss\fP NULL ʳǡ\fIss_flags\fP եɤ
.B SS_DISABLE
ʳ 0 ǤʤͤˤʤäƤ롣
.TP
.B ENOMEM
إʥ륹å (\fIss.ss_size\fP) ˻ꤷ
\fBMINSTKSZ\fP 꾮
.TP
.B EPERM
إʥ륹åͭǤȤѹԤȤ
(Ĥޤꡢץ˸ߤإʥ륹åǼ¹ԤƤ)
.SH
SUSv2, SVr4, POSIX.1-2001.
.SH
إʥ륹åѤǤ褯̤ϡ
.B SIGSEGV
ʥȤǤ롣
.B SIGSEGV
ϥץ̾ΥåѤǤ֤Ȥ̤줿ݤ
륷ʥǤ롣ξˤϡ
.B SIGSEGV
ѤΥʥϥɥץΥåǤϵư뤳ȤǤʤ
ΤᡢΥʥȤˤϡ
إʥ륹åѤʤФʤʤ
.P
ץɸΥʥ륹åȤ̤Ȥͽۤϡ
إʥ륹åΩǤ롣
㤨СåǾ̥ɥ쥹
̥ɥ쥹ˤѤޤƤޤȤǡ
Dz̥ɥ쥹̥ɥ쥹ѤޤҡפȤ֤ĤäƤޤ䡢
\fBsetrlimit(RLIMIT_STACK, &rlim)\fP θƤӽФdzΩ줿
¤ãƤޤäˡͤʻ롣
ɸΥåȤ̤Ƥޤȡ
ͥϥץ \fBSIGSEGV\fP ʥ롣
Τ褦ʾǤϡإʥ륹åǤʥåǤʤ
.P
Linux ݡȤ¿ΥϡɥƥǤϡ
åϲ̥ɥ쥹Ѥޤ롣
.BR sigaltstack ()
ϥåѤޤưŪ˷ꤹ롣
.P
إʥ륹åǼ¹ԤƤ
ʥϥɥ餫ƤФؿ⡢إʥϥɥȤ
(ץإʥ륹åǼ¹ԤƤ硢
¾ΥʥǸƤӽФϥɥ⤳إʥϥɥȤ)
ɸΥåȤϰۤʤꡢ
ƥإʥ륹åưŪ˳ĥʤ
إʥ륹åѤ˳ݤۤ硢
̤ͽۤǤʤ
.P
.BR execve (2)
θƤӽФȡ
¸Ƥإʥ륹å롣
.P
.BR sigaltstack ()
ϰ
.BR sigstack ()
֤ΤǤ롣
ץȤθߴΤᡢglibc Ǥ
.BR sigstack ()
Ƥ롣
Υץꥱ
.BR sigaltstack ()
Ȥäƽ٤Ǥ롣
.SS
4.2BSD ˤ
.BR sigstack ()
ƥॳ뤬ä
δؿϾۤʤä¤ΤȤäƤꡢ
ƤӽФ¦åѤޤΤäƤʤФʤʤȤ
礭ʷä
.SH
ʲΥɤ
.BR sigaltstack ()
λˡΰ:
.in +4n
.nf
stack_t ss;
ss.ss_sp = malloc(SIGSTKSZ);
if (ss.ss_sp == NULL)
/* ϥɥ륨顼 */;
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;
if (sigaltstack(&ss, NULL) == \-1)
/* ϥɥ륨顼 */;
.fi
.in
.SH Ϣ
.BR execve (2),
.BR setrlimit (2),
.BR sigaction (2),
.BR siglongjmp (3),
.BR sigsetjmp (3),
.BR signal (7)
|