OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / release / 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 .SH Ì¾Á°
58 signal \- ANSI C ¥·¥°¥Ê¥ëÁàºî
59 .SH ½ñ¼°
60 .B #include <signal.h>
61 .sp
62 .B typedef void (*sighandler_t)(int);
63 .sp
64 .BI "sighandler_t signal(int " signum ", sighandler_t " sighandler );
65 .SH ÀâÌÀ
66 .BR signal ()
67 ¤ÎÆ°ºî¤Ï UNIX ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤ê°Û¤Ê¤ë¡£
68 ¤Þ¤¿¡¢Îò»ËŪ¤Ë¸«¤Æ Linux ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤Ã¤Æ¤â°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
69 \fB¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î»ÈÍѤÏÈò¤±¡¢\fP
70 Âå¤ï¤ê¤Ë
71 .BR sigaction (2)
72 ¤ò»ÈÍѤ¹¤ë¤³¤È¡£
73 ²¼µ­¤Î¡Ö°Ü¿¢À­¡×¤ò»²¾È¡£
74
75 .BR signal ()
76 ¤Ï¥·¥°¥Ê¥ë
77 .I signum
78 ¤Î½èÍýÊýË¡¤ò
79 .I handler
80 ¤ËÀßÄꤹ¤ë¡£
81 .I handler
82 ¤Ë¤Ï¡¢
83 .BR SIG_IGN "¡¢"
84 .BR SIG_DFL "¡¢"
85 ¥×¥í¥°¥é¥Þ¤¬ÄêµÁ¤·¤¿´Ø¿ô (¡Ö¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¡×) ¤Î¥¢¥É¥ì¥¹¤Î
86 ¤¤¤º¤ì¤«¤ò»ØÄꤹ¤ë¡£
87
88 ¥·¥°¥Ê¥ë
89 .I signum
90 ¤¬¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢°Ê²¼¤Î¤¤¤º¤ì¤«¤¬È¯À¸¤¹¤ë¡£
91 .TP 3
92 *
93 ½èÍýÊýË¡¤¬
94 .B SIG_IGN
95 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤½¤Î¥·¥°¥Ê¥ë¤Ï̵»ë¤µ¤ì¤ë¡£
96 .TP
97 *
98 ½èÍýÊýË¡¤¬
99 .B SIG_DFL
100 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥·¥°¥Ê¥ë¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿
101 ¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤¬¹Ô¤ï¤ì¤ë
102 .RB ( signal (7)
103 »²¾È)¡£
104 .TP
105 *
106 ½èÍýÊýË¡¤È¤·¤Æ´Ø¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
107 ¤Þ¤ººÇ½é¤Ë½èÍýÊýË¡¤¬
108 .B SIG_DFL
109 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¤«¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬¼Â¹Ô¤µ¤ì¤¿¸å¡¢
110 .I signum
111 ¤ò°ú¤­¿ô¤È¤·¤Æ
112 .I handler
113 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
114 ¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤Ë¥·¥°¥Ê¥ë¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤¿¾ì¹ç¡¢
115 ¥Ï¥ó¥É¥é¤¬ÊÖ¤ëºÝ¤Ë¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬²ò½ü¤µ¤ì¤ë¡£
116 .PP
117 ¥·¥°¥Ê¥ë
118 .B SIGKILL
119 ¤È
120 .B SIGSTOP
121 ¤ÏÊ᪤Ǥ­¤º¡¢Ìµ»ë¤¹¤ë¤³¤È¤â¤Ç¤­¤Ê¤¤¡£
122 .SH ÊÖ¤êÃÍ
123 .BR signal ()
124 ¤Ï¡¢º£¤Þ¤Ç¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤ÎÃͤòÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï
125 .B SIG_ERR
126 ¤òÊÖ¤¹¡£
127 .SH ¥¨¥é¡¼
128 .TP
129 .B EINVAL
130 .I signum
131 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
132 .SH ½àµò
133 C89, C99, POSIX.1-2001.
134 .SH Ãí°Õ
135 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥»¥¹¤Ë¤ª¤±¤ë
136 .BR signal ()
137 ¤Î·ë²Ì¤Ï¡¢»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
138 .PP
139 POSIX ¤Ë¤è¤ë¤È¡¢
140 .BR kill (2)
141 ¤ä
142 .BR raise (3)
143 ¤ÇÀ¸À®¤Ç¤­¤Ê¤¤
144 .BR SIGFPE ,
145 .BR SIGILL ,
146 .B SIGSEGV
147 ¥·¥°¥Ê¥ë¤ò̵»ë¤·¤¿¸å¤ÎÆ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
148 0 ¤Ë¤è¤ëÀ°¿ô³ä¤ê»»¤Î·ë²Ì¤Ï̤ÄêµÁ¤È¤Ê¤ë¡£
149 ¤¢¤ë¼ï¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢¤³¤ì¤Ï
150 .B SIGFPE
151 ¥·¥°¥Ê¥ë¤òÀ¸À®¤¹¤ë¡£
152 (ƱÍͤËÉé¤ÎºÇÂçÀ°¿ô¤ò \-1 ¤Ç³ä¤ë¤È
153 .B SIGFPE
154 ¤¬À¸À®¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£)
155 ¤³¤Î¥·¥°¥Ê¥ë¤ò̵»ë¤¹¤ë¤È̵¸Â¥ë¡¼¥×¤Ë´Ù¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
156 .PP
157 .B SIGCHLD
158 ¤ÎÆ°ºî¤È¤·¤Æ
159 .B SIG_IGN
160 ¤òÀßÄꤷ¤¿¾ì¹ç¤Î¾ÜºÙ¤ÊÆ°ºî¤Ë¤Ä¤¤¤Æ¤Ï¡¢
161 .BR sigaction (2)
162 ¤ò»²¾È¤¹¤ë¤³¤È¡£
163 .PP
164 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥éÆ⤫¤é°ÂÁ´¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤ë¡¢
165 async-signal-safe functions (ÈóƱ´ü¥·¥ó¥°¥ë¤Ç°ÂÁ´¤Ê´Ø¿ô) ¤Î
166 ¥ê¥¹¥È¤Ë¤Ä¤¤¤Æ¤Ï
167 .BR signal (7)
168 ¤ò»²¾È¡£
169 .PP
170 .I sighandler_t
171 ¤Î»ÈÍѤϠGNU ³ÈÄ¥¤Ç¤¢¤ë¡£
172 ³Æ¼ï¥Ð¡¼¥¸¥ç¥ó¤Î libc ¤Ç¤³¤Î·¿¤ÏÄêµÁºÑ¤ß¤Ç¤¢¤ë;
173 libc4 ¤È libc5 ¤Ç¤Ï
174 .I SignalHandler
175 ¤òÄêµÁ¤·¤Æ¤¤¤ë¡£
176 glibc ¤Ç¤Ï
177 .I sig_t
178 ¤òÄêµÁ¤·¤Æ¤ª¤ê¡¢
179 .B _GNU_SOURCE
180 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
181 .I sighandler_t
182 ¤âÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
183 ¤³¤Î¤è¤¦¤Ê·¿¤ò»ÈÍѤ·¤Ê¤¤¤È¡¢
184 .BR signal ()
185 ¤ÎÀë¸À¤ÏÆɤߤˤ¯¤¤¤â¤Î¤È¤Ê¤ë¡£
186 .in +4n
187 .nf
188
189 .BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);"
190 .fi
191 .in
192 .SS °Ü¿¢À­
193 °Ü¿¢À­¤Î¤¢¤ë
194 .BR signal ()
195 ¤Î»È¤¤Êý¤Ï¡¢¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤ò
196 .BR SIG_DFL
197 ¤«
198 .BR SIG_IGN
199 ¤ËÀßÄꤹ¤ëÊýË¡¤À¤±¤Ç¤¢¤ë¡£
200 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ë¤Î¤Ë
201 .BR signal ()
202 ¤ò»È¤Ã¤¿¤È¤­¤ÎÆ°ºî¤Ï¥·¥¹¥Æ¥à¤Ë¤è¤ê°Û¤Ê¤ë
203 (POSIX.1 ¤ÏÌÀ¼¨Åª¤Ë¤³¤Î°ã¤¤¤òǧ¤á¤Æ¤¤¤ë)¡£
204 .B "°Ü¿¢À­¤¬É¬ÍפʤȤ­¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»ÈÍѤ·¤Ê¤¤¤³¤È¡£"
205
206 POSIX.1 ¤Ï¡¢
207 .BR sigaction (2)
208 ¤òµ¬Äꤹ¤ë¤³¤È¤Ç°Ü¿¢À­¤Ë´Ø¤¹¤ëº®Íð¤ò²ò·è¤·¤¿¡£
209 .BR sigaction (2)
210 ¤Ï¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤ÎµóÆ°¤òÌÀ¼¨Åª¤ËÀ©¸æ¤Ç¤­¤ë¡£
211 .BR signal ()
212 ¤ÎÂå¤ï¤ê¤Ë¤³¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤ò»È¤¦¤³¤È¡£
213
214 ¥ª¥ê¥¸¥Ê¥ë¤Î UNIX ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
215 .BR signal ()
216 ¤ò»È¤Ã¤ÆÀßÄꤵ¤ì¤¿¥Ï¥ó¥É¥é¤¬¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤êµ¯Æ°¤µ¤ì¤ë¤È¡¢
217 ¤½¤Î¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï
218 .B SIG_DFL
219 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¡¢¥·¥¹¥Æ¥à¤ÏƱ¤¸¥·¥°¥Ê¥ë¤¬¤µ¤é¤ËÀ¸À®¤µ¤ì¤Æ¤â
220 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤ò¥Ö¥í¥Ã¥¯¤·¤Ê¤«¤Ã¤¿¡£
221 System V ¤Ç¤â¡¢
222 .BR signal ()
223 ¤ËÂФ·¤Æ¤³¤ì¤é¤ÎµóÆ°¤òµ¬Äꤷ¤Æ¤¤¤ë¡£
224 ¤³¤¦¤·¤¿µóÆ°¤Ï¤Þ¤º¤¯¡¢¥Ï¥ó¥É¥é¤¬¥Ï¥ó¥É¥é¼«¿È¤òºÆÀßÄꤹ¤ëµ¡²ñ¤¬
225 Íè¤ë¤è¤êÁ°¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬¤Þ¤¿ÇÛÁ÷¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
226 ¤µ¤é¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬Î©¤Æ³¤±¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬
227 ¥Ï¥ó¥É¥é¤ò·«¤êÊÖ¤·µ¯Æ°¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
228
229 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë½èÍý¤ÎµóÆ°¤òÊѹ¹¤¹¤ë¤³¤È¤Ç¡¢¤³¤Î¾õ¶·¤ò²þÁ±¤·¤¿
230 (¤·¤«¤·¡¢»ÄÇ°¤Ê¤³¤È¤Ë¡¢
231 .BR signal ()
232 ¤ò»È¤Ã¤Æ¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ëºÝ¤ËµóÆ°¤¬ÌۤäÆÊѹ¹¤µ¤ì¤ë)¡£
233 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤¿ºÝ¡¢
234 ¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï¥ê¥»¥Ã¥È¤µ¤ì¤º¡¢
235 ¥Ï¥ó¥É¥é¤Î¼Â¹ÔÃæ¤Ï¡¢Æ±¤¸¥·¥°¥Ê¥ë¤Î¤µ¤é¤Ê¤ëÀ¸À®¤ÏÇÛÁ÷¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤ë¡£
236
237 Linux ¤Ç¤Î¾õ¶·¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
238 .IP * 2
239 ¥«¡¼¥Í¥ë¤Î
240 .BR signal ()
241 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï System V Êý¼°¤òÄ󶡤·¤Æ¤¤¤ë¡£
242 .IP *
243 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢glibc 2 °Ê¹ß¤Ç¤Ï¡¢
244 .BR signal ()
245 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¥«¡¼¥Í¥ë¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤òµ¯Æ°¤·¤Ê¤¤¡£
246 Âå¤ï¤ê¤Ë¡¢¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï BSD Êý¼°¤ò¼¨¤¹¥Õ¥é¥°¤ò»È¤Ã¤Æ
247 .BR sigaction (2)
248 ¤ò¸Æ¤Ó½Ð¤¹¡£
249 µ¡Ç½¸¡ºº¥Þ¥¯¥í
250 .B _BSD_SOURCE
251 ¤òÄêµÁ¤·¤Æ¤¤¤ì¤Ð¡¢¤³¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤È¤Ê¤ë¡£
252 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢
253 .B _BSD_SOURCE
254 ¤¬ÄêµÁ¤µ¤ì¤ë¡£
255 .B _BSD_SOURCE
256 ¤Ï
257 .B _GNU_SOURCE
258 ¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï°ÅÌۤΤ¦¤Á¤ËÄêµÁ¤µ¤ì¡¢
259 ¤â¤Á¤í¤óÌÀ¼¨Åª¤ËÄêµÁ¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£
260 .sp
261 glibc 2 °Ê¹ß¤Ç¤Ï¡¢µ¡Ç½¸¡ºº¥Þ¥¯¥í
262 .B _BSD_SOURCE
263 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
264 .BR signal ()
265 ¤Ï System V Êý¼°¤È¤Ê¤ë¡£
266 .RB ( gcc (1)
267 ¤¬É¸½à»ØÄê¥â¡¼¥É
268 .RI ( -std=xxx " or " -ansi )
269 ¤Çµ¯Æ°¤µ¤ì¤¿¾ì¹ç¡¢¤â¤·¤¯¤Ï
270 .BR _POSIX_SOURCE ,
271 .BR _XOPEN_SOURCE ,
272 .B _SVID_SOURCE
273 ¤È¤¤¤Ã¤¿Â¾¤ÎÍÍ¡¹¤Êµ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¡¢
274 ¥Ç¥Õ¥©¥ë¥È¤Î
275 .B _BSD_SOURCE
276 ¤Î°ÅÌÛ¤ÎÄêµÁ¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
277 .BR feature_test_macros (7)
278 ¤ò»²¾È¤Î¤³¤È¡£)
279 .\"
280 .\" System V semantics are also provided if one uses the separate
281 .\" .BR sysv_signal (3)
282 .\" function.
283 .IP *
284 Linux ¤Î libc4 ¤È libc5 ¤Î
285 .BR signal ()
286 ´Ø¿ô¤Ï System V Êý¼°¤Ç¤¢¤ë¡£
287 libc5 ¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ
288 .I <signal.h>
289 ¤Î¤«¤ï¤ê¤Ë
290 .I <bsd/signal.h>
291 ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤È¡¢
292 .BR signal ()
293 ¤Ï
294 .BR __bsd_signal ()
295 ¤ËºÆÄêµÁ¤µ¤ì¡¢
296 .BR signal ()
297 ¤Ï BSD Êý¼°¤È¤Ê¤ë¡£
298 .SH ´ØÏ¢¹àÌÜ
299 .BR kill (1),
300 .BR alarm (2),
301 .BR kill (2),
302 .BR killpg (2),
303 .BR pause (2),
304 .BR sigaction (2),
305 .BR signalfd (2),
306 .BR sigpending (2),
307 .BR sigprocmask (2),
308 .BR sigsuspend (2),
309 .BR bsd_signal (3),
310 .BR raise (3),
311 .BR siginterrupt (3),
312 .BR sigqueue (3),
313 .BR sigsetops (3),
314 .BR sigvec (3),
315 .BR sysv_signal (3),
316 .BR signal (7)