OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man2 / signal.2
1 .\" Copyright (c) 2000 Andries Brouwer <aeb@cwi.nl>
2 .\" and Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
3 .\"      <mtk.manpages@gmail.com>
4 .\" and Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
5 .\"      <mtk.manpages@gmail.com>
6 .\" based on work by Rik Faith <faith@cs.unc.edu>
7 .\" and Mike Battersby <mike@starbug.apana.org.au>.
8 .\"
9 .\" Permission is granted to make and distribute verbatim copies of this
10 .\" manual provided the copyright notice and this permission notice are
11 .\" preserved on all copies.
12 .\"
13 .\" Permission is granted to copy and distribute modified versions of this
14 .\" manual under the conditions for verbatim copying, provided that the
15 .\" entire resulting derived work is distributed under the terms of a
16 .\" permission notice identical to this one.
17 .\"
18 .\" Since the Linux kernel and libraries are constantly changing, this
19 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
20 .\" responsibility for errors or omissions, or for damages resulting from
21 .\" the use of the information contained herein.  The author(s) may not
22 .\" have taken the same level of care in the production of this manual,
23 .\" which is licensed free of charge, as they might when working
24 .\" professionally.
25 .\"
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
28 .\"
29 .\" Modified 2004-11-19, mtk:
30 .\" added pointer to sigaction.2 for details of ignoring SIGCHLD
31 .\" 2007-06-03, mtk: strengthened portability warning, and rewrote
32 .\"     various sections.
33 .\" 2008-07-11, mtk: rewrote and expanded portability discussion.
34 .\"
35 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
36 .\"         all rights reserved.
37 .\" Translated 1997-03-03, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Modified 2000-09-24, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Updated & Modified 2002-01-14, Yuichi SATO <ysato@h4.dion.ne.jp>
40 .\" Updated & Modified 2004-01-17, Yuichi SATO <ysato444@yahoo.co.jp>
41 .\" Updated & Modified 2005-01-07, Yuichi SATO
42 .\" Updated 2007-06-01, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.50
43 .\" Updated 2007-06-13, Akihiro MOTOKI, LDP v2.55
44 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
45 .\"
46 .\"WORD:        signal                  ¥·¥°¥Ê¥ë
47 .\"WORD:        signal handler          ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é
48 .\"WORD:        library                 ¥é¥¤¥Ö¥é¥ê
49 .\"WORD:        semantics               Êý¼°
50 .\"WORD:        prototype               ·¿Àë¸À
51 .\"WORD:        architecture            ¥¢¡¼¥­¥Æ¥¯¥Á¥ã¡¼
52 .\"WORD:        endless loop            Ìµ¸Â¥ë¡¼¥×
53 .\"WORD:        feature test macro      µ¡Ç½¸¡ºº¥Þ¥¯¥í
54 .\"WORD:        disposition             ½èÍýÊýË¡
55 .\"
56 .TH SIGNAL 2 2008-07-11 "Linux" "Linux Programmer's Manual"
57 .\"O .SH NAME
58 .SH Ì¾Á°
59 .\"O signal \- ANSI C signal handling
60 signal \- ANSI C ¥·¥°¥Ê¥ëÁàºî
61 .\"O .SH SYNOPSIS
62 .SH ½ñ¼°
63 .B #include <signal.h>
64 .sp
65 .B typedef void (*sighandler_t)(int);
66 .sp
67 .\"O .BI "sighandler_t signal(int " signum ", sighandler_t " handler );
68 .BI "sighandler_t signal(int " signum ", sighandler_t " sighandler );
69 .\"O .SH DESCRIPTION
70 .SH ÀâÌÀ
71 .\"O The behavior of
72 .\"O .BR signal ()
73 .\"O varies across UNIX versions,
74 .\"O and has also varied historically across different versions of Linux.
75 .\"O \fBAvoid its use\fP: use
76 .\"O .BR sigaction (2)
77 .\"O instead.
78 .\"O See \fIPortability\fP below.
79 .BR signal ()
80 ¤ÎÆ°ºî¤Ï UNIX ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤ê°Û¤Ê¤ë¡£
81 ¤Þ¤¿¡¢Îò»ËŪ¤Ë¸«¤Æ Linux ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤Ã¤Æ¤â°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
82 \fB¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î»ÈÍѤÏÈò¤±¡¢\fP
83 Âå¤ï¤ê¤Ë
84 .BR sigaction (2)
85 ¤ò»ÈÍѤ¹¤ë¤³¤È¡£
86 ²¼µ­¤Î¡Ö°Ü¿¢À­¡×¤ò»²¾È¡£
87
88 .\"O .BR signal ()
89 .\"O sets the disposition of the signal
90 .\"O .I signum
91 .\"O to
92 .\"O .IR handler ,
93 .\"O which is either
94 .\"O .BR SIG_IGN ,
95 .\"O .BR SIG_DFL ,
96 .\"O or the address of a programmer-defined function (a "signal handler").
97 .BR signal ()
98 ¤Ï¥·¥°¥Ê¥ë
99 .I signum
100 ¤Î½èÍýÊýË¡¤ò
101 .I handler
102 ¤ËÀßÄꤹ¤ë¡£
103 .I handler
104 ¤Ë¤Ï¡¢
105 .BR SIG_IGN "¡¢"
106 .BR SIG_DFL "¡¢"
107 ¥×¥í¥°¥é¥Þ¤¬ÄêµÁ¤·¤¿´Ø¿ô (¡Ö¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¡×) ¤Î¥¢¥É¥ì¥¹¤Î
108 ¤¤¤º¤ì¤«¤ò»ØÄꤹ¤ë¡£
109
110 .\"O If the signal
111 .\"O .I signum
112 .\"O is delivered to the process, then one of the following happens:
113 ¥·¥°¥Ê¥ë
114 .I signum
115 ¤¬¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢°Ê²¼¤Î¤¤¤º¤ì¤«¤¬È¯À¸¤¹¤ë¡£
116 .TP 3
117 *
118 .\"O If the disposition is set to
119 .\"O .BR SIG_IGN ,
120 .\"O then the signal is ignored.
121 ½èÍýÊýË¡¤¬
122 .B SIG_IGN
123 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤½¤Î¥·¥°¥Ê¥ë¤Ï̵»ë¤µ¤ì¤ë¡£
124 .TP
125 *
126 .\"O If the disposition is set to
127 .\"O .BR SIG_DFL ,
128 .\"O then the default action associated with the signal (see
129 .\"O .BR signal (7))
130 .\"O occurs.
131 ½èÍýÊýË¡¤¬
132 .B SIG_DFL
133 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥·¥°¥Ê¥ë¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿
134 ¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤¬¹Ô¤ï¤ì¤ë
135 .RB ( signal (7)
136 »²¾È)¡£
137 .TP
138 *
139 .\"O If the disposition is set to a function,
140 .\"O then first either the disposition is reset to
141 .\"O .BR SIG_DFL ,
142 .\"O or the signal is blocked (see \fIPortability\fP below), and then
143 .\"O .I handler
144 .\"O is called with argument
145 .\"O .IR signum .
146 ½èÍýÊýË¡¤È¤·¤Æ´Ø¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
147 ¤Þ¤ººÇ½é¤Ë½èÍýÊýË¡¤¬
148 .B SIG_DFL
149 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¤«¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬¼Â¹Ô¤µ¤ì¤¿¸å¡¢
150 .I signum
151 ¤ò°ú¤­¿ô¤È¤·¤Æ
152 .I handler
153 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
154 .\"O If invocation of the handler caused the signal to be blocked,
155 .\"O then the signal is unblocked upon return from the handler.
156 ¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤Ë¥·¥°¥Ê¥ë¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤¿¾ì¹ç¡¢
157 ¥Ï¥ó¥É¥é¤¬ÊÖ¤ëºÝ¤Ë¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬²ò½ü¤µ¤ì¤ë¡£
158 .PP
159 .\"O The signals
160 .\"O .B SIGKILL
161 .\"O and
162 .\"O .B SIGSTOP
163 .\"O cannot be caught or ignored.
164 ¥·¥°¥Ê¥ë
165 .B SIGKILL
166 ¤È
167 .B SIGSTOP
168 ¤ÏÊ᪤Ǥ­¤º¡¢Ìµ»ë¤¹¤ë¤³¤È¤â¤Ç¤­¤Ê¤¤¡£
169 .\"O .SH "RETURN VALUE"
170 .SH ÊÖ¤êÃÍ
171 .\"O .BR signal ()
172 .\"O returns the previous value of the signal handler, or
173 .\"O .B SIG_ERR
174 .\"O on error.
175 .BR signal ()
176 ¤Ï¡¢º£¤Þ¤Ç¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤ÎÃͤòÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï
177 .B SIG_ERR
178 ¤òÊÖ¤¹¡£
179 .\"O .SH ERRORS
180 .SH ¥¨¥é¡¼
181 .TP
182 .B EINVAL
183 .\"O .I signum
184 .\"O is invalid.
185 .I signum
186 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
187 .\"O .SH "CONFORMING TO"
188 .SH ½àµò
189 C89, C99, POSIX.1-2001.
190 .\"O .SH NOTES
191 .SH Ãí°Õ
192 .\"O The effects of
193 .\"O .BR signal ()
194 .\"O in a multithreaded process are unspecified.
195 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥»¥¹¤Ë¤ª¤±¤ë
196 .BR signal ()
197 ¤Î·ë²Ì¤Ï¡¢»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
198 .PP
199 .\"O According to POSIX, the behavior of a process is undefined after it
200 .\"O ignores a
201 .\"O .BR SIGFPE ,
202 .\"O .BR SIGILL ,
203 .\"O or
204 .\"O .B SIGSEGV
205 .\"O signal that was not generated by
206 .\"O .BR kill (2)
207 .\"O or
208 .\"O .BR raise (3).
209 POSIX ¤Ë¤è¤ë¤È¡¢
210 .BR kill (2)
211 ¤ä
212 .BR raise (3)
213 ¤ÇÀ¸À®¤Ç¤­¤Ê¤¤
214 .BR SIGFPE ,
215 .BR SIGILL ,
216 .B SIGSEGV
217 ¥·¥°¥Ê¥ë¤ò̵»ë¤·¤¿¸å¤ÎÆ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
218 .\"O Integer division by zero has undefined result.
219 .\"O On some architectures it will generate a
220 .\"O .B SIGFPE
221 .\"O signal.
222 .\"O (Also dividing the most negative integer by \-1 may generate
223 .\"O .BR SIGFPE .)
224 .\"O Ignoring this signal might lead to an endless loop.
225 0 ¤Ë¤è¤ëÀ°¿ô³ä¤ê»»¤Î·ë²Ì¤Ï̤ÄêµÁ¤È¤Ê¤ë¡£
226 ¤¢¤ë¼ï¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢¤³¤ì¤Ï
227 .B SIGFPE
228 ¥·¥°¥Ê¥ë¤òÀ¸À®¤¹¤ë¡£
229 (ƱÍͤËÉé¤ÎºÇÂçÀ°¿ô¤ò \-1 ¤Ç³ä¤ë¤È
230 .B SIGFPE
231 ¤¬À¸À®¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£)
232 ¤³¤Î¥·¥°¥Ê¥ë¤ò̵»ë¤¹¤ë¤È̵¸Â¥ë¡¼¥×¤Ë´Ù¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
233 .PP
234 .\"O See
235 .\"O .BR sigaction (2)
236 .\"O for details on what happens when
237 .\"O .B SIGCHLD
238 .\"O is set to
239 .\"O .BR SIG_IGN .
240 .B SIGCHLD
241 ¤ÎÆ°ºî¤È¤·¤Æ
242 .B SIG_IGN
243 ¤òÀßÄꤷ¤¿¾ì¹ç¤Î¾ÜºÙ¤ÊÆ°ºî¤Ë¤Ä¤¤¤Æ¤Ï¡¢
244 .BR sigaction (2)
245 ¤ò»²¾È¤¹¤ë¤³¤È¡£
246 .PP
247 .\"O See
248 .\"O .BR signal (7)
249 .\"O for a list of the async-signal-safe functions that can be
250 .\"O safely called from inside a signal handler.
251 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥éÆ⤫¤é°ÂÁ´¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤ë¡¢
252 async-signal-safe functions (ÈóƱ´ü¥·¥ó¥°¥ë¤Ç°ÂÁ´¤Ê´Ø¿ô) ¤Î
253 ¥ê¥¹¥È¤Ë¤Ä¤¤¤Æ¤Ï
254 .BR signal (7)
255 ¤ò»²¾È¡£
256 .PP
257 .\"O The use of
258 .\"O .I sighandler_t
259 .\"O is a GNU extension.
260 .I sighandler_t
261 ¤Î»ÈÍѤϠGNU ³ÈÄ¥¤Ç¤¢¤ë¡£
262 .\"O Various versions of libc predefine this type; libc4 and libc5 define
263 .\"O .IR SignalHandler ;
264 .\"O glibc defines
265 .\"O .I sig_t
266 .\"O and, when
267 .\"O .B _GNU_SOURCE
268 .\"O is defined, also
269 .\"O .IR sighandler_t .
270 ³Æ¼ï¥Ð¡¼¥¸¥ç¥ó¤Î libc ¤Ç¤³¤Î·¿¤ÏÄêµÁºÑ¤ß¤Ç¤¢¤ë;
271 libc4 ¤È libc5 ¤Ç¤Ï
272 .I SignalHandler
273 ¤òÄêµÁ¤·¤Æ¤¤¤ë¡£
274 glibc ¤Ç¤Ï
275 .I sig_t
276 ¤òÄêµÁ¤·¤Æ¤ª¤ê¡¢
277 .B _GNU_SOURCE
278 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
279 .I sighandler_t
280 ¤âÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
281 .\"O Without use of such a type, the declaration of
282 .\"O .BR signal ()
283 .\"O is the somewhat harder to read:
284 ¤³¤Î¤è¤¦¤Ê·¿¤ò»ÈÍѤ·¤Ê¤¤¤È¡¢
285 .BR signal ()
286 ¤ÎÀë¸À¤ÏÆɤߤˤ¯¤¤¤â¤Î¤È¤Ê¤ë¡£
287 .in +4n
288 .nf
289
290 .BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);"
291 .fi
292 .in
293 .\"O .SS PORTABILITY
294 .SS °Ü¿¢À­
295 .\"O The only portable use of
296 .\"O .BR signal ()
297 .\"O is to set a signal's disposition to
298 .\"O .BR SIG_DFL
299 .\"O or
300 .\"O .BR SIG_IGN .
301 .\"O The semantics when using
302 .\"O .BR signal ()
303 .\"O to establish a signal handler vary across systems
304 .\"O (and POSIX.1 explicitly permits this variation);
305 .\"O .B do not use it for this purpose.
306 °Ü¿¢À­¤Î¤¢¤ë
307 .BR signal ()
308 ¤Î»È¤¤Êý¤Ï¡¢¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤ò
309 .BR SIG_DFL
310 ¤«
311 .BR SIG_IGN
312 ¤ËÀßÄꤹ¤ëÊýË¡¤À¤±¤Ç¤¢¤ë¡£
313 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ë¤Î¤Ë
314 .BR signal ()
315 ¤ò»È¤Ã¤¿¤È¤­¤ÎÆ°ºî¤Ï¥·¥¹¥Æ¥à¤Ë¤è¤ê°Û¤Ê¤ë
316 (POSIX.1 ¤ÏÌÀ¼¨Åª¤Ë¤³¤Î°ã¤¤¤òǧ¤á¤Æ¤¤¤ë)¡£
317 .B "°Ü¿¢À­¤¬É¬ÍפʤȤ­¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»ÈÍѤ·¤Ê¤¤¤³¤È¡£"
318
319 .\"O POSIX.1 solved the portability mess by specifying
320 .\"O .BR sigaction (2),
321 .\"O which provides explicit control of the semantics when a
322 .\"O signal handler is invoked; use that interface instead of
323 .\"O .BR signal ().
324 POSIX.1 ¤Ï¡¢
325 .BR sigaction (2)
326 ¤òµ¬Äꤹ¤ë¤³¤È¤Ç°Ü¿¢À­¤Ë´Ø¤¹¤ëº®Íð¤ò²ò·è¤·¤¿¡£
327 .BR sigaction (2)
328 ¤Ï¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤ÎµóÆ°¤òÌÀ¼¨Åª¤ËÀ©¸æ¤Ç¤­¤ë¡£
329 .BR signal ()
330 ¤ÎÂå¤ï¤ê¤Ë¤³¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤ò»È¤¦¤³¤È¡£
331
332 .\"O In the original UNIX systems, when a handler that was established using
333 .\"O .BR signal ()
334 .\"O was invoked by the delivery of a signal,
335 .\"O the disposition of the signal would be reset to
336 .\"O .BR SIG_DFL ,
337 .\"O and the system did not block delivery of further instances of the signal.
338 .\"O System V also provides these semantics for
339 .\"O .BR signal ().
340 .\"O This was bad because the signal might be delivered again
341 .\"O before the handler had a chance to reestablish itself.
342 .\"O Furthermore, rapid deliveries of the same signal could
343 .\"O result in recursive invocations of the handler.
344 ¥ª¥ê¥¸¥Ê¥ë¤Î UNIX ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
345 .BR signal ()
346 ¤ò»È¤Ã¤ÆÀßÄꤵ¤ì¤¿¥Ï¥ó¥É¥é¤¬¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤êµ¯Æ°¤µ¤ì¤ë¤È¡¢
347 ¤½¤Î¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï
348 .B SIG_DFL
349 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¡¢¥·¥¹¥Æ¥à¤ÏƱ¤¸¥·¥°¥Ê¥ë¤¬¤µ¤é¤ËÀ¸À®¤µ¤ì¤Æ¤â
350 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤ò¥Ö¥í¥Ã¥¯¤·¤Ê¤«¤Ã¤¿¡£
351 System V ¤Ç¤â¡¢
352 .BR signal ()
353 ¤ËÂФ·¤Æ¤³¤ì¤é¤ÎµóÆ°¤òµ¬Äꤷ¤Æ¤¤¤ë¡£
354 ¤³¤¦¤·¤¿µóÆ°¤Ï¤Þ¤º¤¯¡¢¥Ï¥ó¥É¥é¤¬¥Ï¥ó¥É¥é¼«¿È¤òºÆÀßÄꤹ¤ëµ¡²ñ¤¬
355 Íè¤ë¤è¤êÁ°¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬¤Þ¤¿ÇÛÁ÷¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
356 ¤µ¤é¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬Î©¤Æ³¤±¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬
357 ¥Ï¥ó¥É¥é¤ò·«¤êÊÖ¤·µ¯Æ°¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
358
359 .\"O BSD improved on this situation by changing the semantics of
360 .\"O signal handling
361 .\"O (but, unfortunately, silently changed the semantics
362 .\"O when establishing a handler with
363 .\"O .BR signal ()).
364 .\"O On BSD, when a signal handler is invoked,
365 .\"O the signal disposition is not reset,
366 .\"O and further instances of the signal are blocked from
367 .\"O being delivered while the handler is executing.
368 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë½èÍý¤ÎµóÆ°¤òÊѹ¹¤¹¤ë¤³¤È¤Ç¡¢¤³¤Î¾õ¶·¤ò²þÁ±¤·¤¿
369 (¤·¤«¤·¡¢»ÄÇ°¤Ê¤³¤È¤Ë¡¢
370 .BR signal ()
371 ¤ò»È¤Ã¤Æ¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ëºÝ¤ËµóÆ°¤¬ÌۤäÆÊѹ¹¤µ¤ì¤ë)¡£
372 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤¿ºÝ¡¢
373 ¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï¥ê¥»¥Ã¥È¤µ¤ì¤º¡¢
374 ¥Ï¥ó¥É¥é¤Î¼Â¹ÔÃæ¤Ï¡¢Æ±¤¸¥·¥°¥Ê¥ë¤Î¤µ¤é¤Ê¤ëÀ¸À®¤ÏÇÛÁ÷¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤ë¡£
375
376 .\"O The situation on Linux is as follows:
377 Linux ¤Ç¤Î¾õ¶·¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
378 .IP * 2
379 .\"O The kernel's
380 .\"O .BR signal ()
381 .\"O system call provides System V semantics.
382 ¥«¡¼¥Í¥ë¤Î
383 .BR signal ()
384 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï System V Êý¼°¤òÄ󶡤·¤Æ¤¤¤ë¡£
385 .IP *
386 .\"O By default, in glibc 2 and later, the
387 .\"O .BR signal ()
388 .\"O wrapper function does not invoke the kernel system call.
389 .\"O Instead, it calls
390 .\"O .BR sigaction (2)
391 .\"O using flags that supply BSD semantics.
392 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢glibc 2 °Ê¹ß¤Ç¤Ï¡¢
393 .BR signal ()
394 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¥«¡¼¥Í¥ë¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤òµ¯Æ°¤·¤Ê¤¤¡£
395 Âå¤ï¤ê¤Ë¡¢¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï BSD Êý¼°¤ò¼¨¤¹¥Õ¥é¥°¤ò»È¤Ã¤Æ
396 .BR sigaction (2)
397 ¤ò¸Æ¤Ó½Ð¤¹¡£
398 .\"O This default behavior is provided as long as the
399 .\"O .B _BSD_SOURCE
400 .\"O feature test macro is defined.
401 .\"O By default,
402 .\"O .B _BSD_SOURCE
403 .\"O is defined;
404 .\"O it is also implicitly defined if one defines
405 .\"O .BR _GNU_SOURCE ,
406 .\"O and can of course be explicitly defined.
407 µ¡Ç½¸¡ºº¥Þ¥¯¥í
408 .B _BSD_SOURCE
409 ¤òÄêµÁ¤·¤Æ¤¤¤ì¤Ð¡¢¤³¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤È¤Ê¤ë¡£
410 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢
411 .B _BSD_SOURCE
412 ¤¬ÄêµÁ¤µ¤ì¤ë¡£
413 .B _BSD_SOURCE
414 ¤Ï
415 .B _GNU_SOURCE
416 ¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï°ÅÌۤΤ¦¤Á¤ËÄêµÁ¤µ¤ì¡¢
417 ¤â¤Á¤í¤óÌÀ¼¨Åª¤ËÄêµÁ¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£
418 .sp
419 .\"O On glibc 2 and later, if the
420 .\"O .B _BSD_SOURCE
421 .\"O feature test macro is not defined, then
422 .\"O .BR signal ()
423 .\"O provides System V semantics.
424 glibc 2 °Ê¹ß¤Ç¤Ï¡¢µ¡Ç½¸¡ºº¥Þ¥¯¥í
425 .B _BSD_SOURCE
426 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
427 .BR signal ()
428 ¤Ï System V Êý¼°¤È¤Ê¤ë¡£
429 .\"O (The default implicit definition of
430 .\"O .B _BSD_SOURCE
431 .\"O is not provided if one invokes
432 .\"O .BR gcc (1)
433 .\"O in one of its standard modes
434 .\"O .RI ( -std=xxx " or " -ansi )
435 .\"O or defines various other feature test macros such as
436 .\"O .BR _POSIX_SOURCE ,
437 .\"O .BR _XOPEN_SOURCE ,
438 .\"O or
439 .\"O .BR _SVID_SOURCE ;
440 .\"O see
441 .\"O .BR feature_test_macros (7).)
442 .RB ( gcc (1)
443 ¤¬É¸½à»ØÄê¥â¡¼¥É
444 .RI ( -std=xxx " or " -ansi )
445 ¤Çµ¯Æ°¤µ¤ì¤¿¾ì¹ç¡¢¤â¤·¤¯¤Ï
446 .BR _POSIX_SOURCE ,
447 .BR _XOPEN_SOURCE ,
448 .B _SVID_SOURCE
449 ¤È¤¤¤Ã¤¿Â¾¤ÎÍÍ¡¹¤Êµ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¡¢
450 ¥Ç¥Õ¥©¥ë¥È¤Î
451 .B _BSD_SOURCE
452 ¤Î°ÅÌÛ¤ÎÄêµÁ¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
453 .BR feature_test_macros (7)
454 ¤ò»²¾È¤Î¤³¤È¡£)
455 .\"
456 .\" System V semantics are also provided if one uses the separate
457 .\" .BR sysv_signal (3)
458 .\" function.
459 .IP *
460 .\"O The
461 .\"O .BR signal ()
462 .\"O function in Linux libc4 and libc5 provide System V semantics.
463 .\"O If one on a libc5 system includes
464 .\"O .I <bsd/signal.h>
465 .\"O instead of
466 .\"O .IR <signal.h> ,
467 .\"O then
468 .\"O .BR signal ()
469 .\"O provides BSD semantics.
470 Linux ¤Î libc4 ¤È libc5 ¤Î
471 .BR signal ()
472 ´Ø¿ô¤Ï System V Êý¼°¤Ç¤¢¤ë¡£
473 libc5 ¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ
474 .I <signal.h>
475 ¤Î¤«¤ï¤ê¤Ë
476 .I <bsd/signal.h>
477 ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤È¡¢
478 .BR signal ()
479 ¤Ï
480 .BR __bsd_signal ()
481 ¤ËºÆÄêµÁ¤µ¤ì¡¢
482 .BR signal ()
483 ¤Ï BSD Êý¼°¤È¤Ê¤ë¡£
484 .\"O .SH "SEE ALSO"
485 .SH ´ØÏ¢¹àÌÜ
486 .BR kill (1),
487 .BR alarm (2),
488 .BR kill (2),
489 .BR killpg (2),
490 .BR pause (2),
491 .BR sigaction (2),
492 .BR signalfd (2),
493 .BR sigpending (2),
494 .BR sigprocmask (2),
495 .BR sigqueue (2),
496 .BR sigsuspend (2),
497 .BR bsd_signal (3),
498 .BR raise (3),
499 .BR siginterrupt (3),
500 .BR sigsetops (3),
501 .BR sigvec (3),
502 .BR sysv_signal (3),
503 .BR feature_test_macros (7),
504 .BR signal (7)