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>.
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.
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.
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
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
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
33 .\" 2008-07-11, mtk: rewrote and expanded portability discussion.
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
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 ½èÍýÊýË¡
56 .TH SIGNAL 2 2008-07-11 "Linux" "Linux Programmer's Manual"
58 signal \- ANSI C ¥·¥°¥Ê¥ëÁàºî
60 .B #include <signal.h>
62 .B typedef void (*sighandler_t)(int);
64 .BI "sighandler_t signal(int " signum ", sighandler_t " sighandler );
67 ¤ÎÆ°ºî¤Ï UNIX ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤ê°Û¤Ê¤ë¡£
68 ¤Þ¤¿¡¢Îò»ËŪ¤Ë¸«¤Æ Linux ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤Ã¤Æ¤â°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
69 \fB¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î»ÈÍѤÏÈò¤±¡¢\fP
73 ²¼µ¤Î¡Ö°Ü¿¢À¡×¤ò»²¾È¡£
85 ¥×¥í¥°¥é¥Þ¤¬ÄêµÁ¤·¤¿´Ø¿ô (¡Ö¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¡×) ¤Î¥¢¥É¥ì¥¹¤Î
90 ¤¬¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢°Ê²¼¤Î¤¤¤º¤ì¤«¤¬È¯À¸¤¹¤ë¡£
95 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤½¤Î¥·¥°¥Ê¥ë¤Ï̵»ë¤µ¤ì¤ë¡£
100 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥·¥°¥Ê¥ë¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿
101 ¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤¬¹Ô¤ï¤ì¤ë
106 ½èÍýÊýË¡¤È¤·¤Æ´Ø¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
109 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¤«¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬¼Â¹Ô¤µ¤ì¤¿¸å¡¢
114 ¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤Ë¥·¥°¥Ê¥ë¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤¿¾ì¹ç¡¢
115 ¥Ï¥ó¥É¥é¤¬ÊÖ¤ëºÝ¤Ë¤½¤Î¥·¥°¥Ê¥ë¤Î¥Ö¥í¥Ã¥¯¤¬²ò½ü¤µ¤ì¤ë¡£
121 ¤ÏÊ᪤Ǥ¤º¡¢Ìµ»ë¤¹¤ë¤³¤È¤â¤Ç¤¤Ê¤¤¡£
124 ¤Ï¡¢º£¤Þ¤Ç¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤ÎÃͤòÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï
133 C89, C99, POSIX.1-2001.
135 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥»¥¹¤Ë¤ª¤±¤ë
137 ¤Î·ë²Ì¤Ï¡¢»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
147 ¥·¥°¥Ê¥ë¤ò̵»ë¤·¤¿¸å¤ÎÆ°ºî¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
148 0 ¤Ë¤è¤ëÀ°¿ô³ä¤ê»»¤Î·ë²Ì¤Ï̤ÄêµÁ¤È¤Ê¤ë¡£
149 ¤¢¤ë¼ï¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢¤³¤ì¤Ï
152 (ƱÍͤËÉé¤ÎºÇÂçÀ°¿ô¤ò \-1 ¤Ç³ä¤ë¤È
154 ¤¬À¸À®¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£)
155 ¤³¤Î¥·¥°¥Ê¥ë¤ò̵»ë¤¹¤ë¤È̵¸Â¥ë¡¼¥×¤Ë´Ù¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
160 ¤òÀßÄꤷ¤¿¾ì¹ç¤Î¾ÜºÙ¤ÊÆ°ºî¤Ë¤Ä¤¤¤Æ¤Ï¡¢
164 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥éÆ⤫¤é°ÂÁ´¤Ë¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤¤ë¡¢
165 async-signal-safe functions (ÈóƱ´ü¥·¥ó¥°¥ë¤Ç°ÂÁ´¤Ê´Ø¿ô) ¤Î
171 ¤Î»ÈÍÑ¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ë¡£
172 ³Æ¼ï¥Ð¡¼¥¸¥ç¥ó¤Î libc ¤Ç¤³¤Î·¿¤ÏÄêµÁºÑ¤ß¤Ç¤¢¤ë;
180 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
183 ¤³¤Î¤è¤¦¤Ê·¿¤ò»ÈÍѤ·¤Ê¤¤¤È¡¢
185 ¤ÎÀë¸À¤ÏÆɤߤˤ¯¤¤¤â¤Î¤È¤Ê¤ë¡£
189 .BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);"
195 ¤Î»È¤¤Êý¤Ï¡¢¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤ò
199 ¤ËÀßÄꤹ¤ëÊýË¡¤À¤±¤Ç¤¢¤ë¡£
200 ¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ë¤Î¤Ë
202 ¤ò»È¤Ã¤¿¤È¤¤ÎÆ°ºî¤Ï¥·¥¹¥Æ¥à¤Ë¤è¤ê°Û¤Ê¤ë
203 (POSIX.1 ¤ÏÌÀ¼¨Åª¤Ë¤³¤Î°ã¤¤¤òǧ¤á¤Æ¤¤¤ë)¡£
204 .B "°Ü¿¢À¤¬É¬ÍפʤȤ¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»ÈÍѤ·¤Ê¤¤¤³¤È¡£"
208 ¤òµ¬Äꤹ¤ë¤³¤È¤Ç°Ü¿¢À¤Ë´Ø¤¹¤ëº®Íð¤ò²ò·è¤·¤¿¡£
210 ¤Ï¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤ëºÝ¤ÎµóÆ°¤òÌÀ¼¨Åª¤ËÀ©¸æ¤Ç¤¤ë¡£
212 ¤ÎÂå¤ï¤ê¤Ë¤³¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤ò»È¤¦¤³¤È¡£
214 ¥ª¥ê¥¸¥Ê¥ë¤Î UNIX ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
216 ¤ò»È¤Ã¤ÆÀßÄꤵ¤ì¤¿¥Ï¥ó¥É¥é¤¬¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤êµ¯Æ°¤µ¤ì¤ë¤È¡¢
217 ¤½¤Î¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï
219 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¡¢¥·¥¹¥Æ¥à¤ÏƱ¤¸¥·¥°¥Ê¥ë¤¬¤µ¤é¤ËÀ¸À®¤µ¤ì¤Æ¤â
220 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤ò¥Ö¥í¥Ã¥¯¤·¤Ê¤«¤Ã¤¿¡£
223 ¤ËÂФ·¤Æ¤³¤ì¤é¤ÎµóÆ°¤òµ¬Äꤷ¤Æ¤¤¤ë¡£
224 ¤³¤¦¤·¤¿µóÆ°¤Ï¤Þ¤º¤¯¡¢¥Ï¥ó¥É¥é¤¬¥Ï¥ó¥É¥é¼«¿È¤òºÆÀßÄꤹ¤ëµ¡²ñ¤¬
225 Íè¤ë¤è¤êÁ°¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬¤Þ¤¿ÇÛÁ÷¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
226 ¤µ¤é¤Ë¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬Î©¤Æ³¤±¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢Æ±¤¸¥·¥°¥Ê¥ë¤¬
227 ¥Ï¥ó¥É¥é¤ò·«¤êÊÖ¤·µ¯Æ°¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
229 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë½èÍý¤ÎµóÆ°¤òÊѹ¹¤¹¤ë¤³¤È¤Ç¡¢¤³¤Î¾õ¶·¤ò²þÁ±¤·¤¿
230 (¤·¤«¤·¡¢»ÄÇ°¤Ê¤³¤È¤Ë¡¢
232 ¤ò»È¤Ã¤Æ¥Ï¥ó¥É¥é¤òÀßÄꤹ¤ëºÝ¤ËµóÆ°¤¬ÌۤäÆÊѹ¹¤µ¤ì¤ë)¡£
233 BSD ¤Ç¤Ï¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬µ¯Æ°¤µ¤ì¤¿ºÝ¡¢
234 ¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡¤Ï¥ê¥»¥Ã¥È¤µ¤ì¤º¡¢
235 ¥Ï¥ó¥É¥é¤Î¼Â¹ÔÃæ¤Ï¡¢Æ±¤¸¥·¥°¥Ê¥ë¤Î¤µ¤é¤Ê¤ëÀ¸À®¤ÏÇÛÁ÷¤¬¥Ö¥í¥Ã¥¯¤µ¤ì¤ë¡£
237 Linux ¤Ç¤Î¾õ¶·¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
241 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï System V Êý¼°¤òÄ󶡤·¤Æ¤¤¤ë¡£
243 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢glibc 2 °Ê¹ß¤Ç¤Ï¡¢
245 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¥«¡¼¥Í¥ë¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤òµ¯Æ°¤·¤Ê¤¤¡£
246 Âå¤ï¤ê¤Ë¡¢¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï BSD Êý¼°¤ò¼¨¤¹¥Õ¥é¥°¤ò»È¤Ã¤Æ
251 ¤òÄêµÁ¤·¤Æ¤¤¤ì¤Ð¡¢¤³¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤È¤Ê¤ë¡£
258 ¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï°ÅÌۤΤ¦¤Á¤ËÄêµÁ¤µ¤ì¡¢
259 ¤â¤Á¤í¤óÌÀ¼¨Åª¤ËÄêµÁ¤¹¤ë¤³¤È¤â¤Ç¤¤ë¡£
261 glibc 2 °Ê¹ß¤Ç¤Ï¡¢µ¡Ç½¸¡ºº¥Þ¥¯¥í
263 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
265 ¤Ï System V Êý¼°¤È¤Ê¤ë¡£
268 .RI ( -std=xxx " or " -ansi )
269 ¤Çµ¯Æ°¤µ¤ì¤¿¾ì¹ç¡¢¤â¤·¤¯¤Ï
273 ¤È¤¤¤Ã¤¿Â¾¤ÎÍÍ¡¹¤Êµ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¡¢
276 ¤Î°ÅÌÛ¤ÎÄêµÁ¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
277 .BR feature_test_macros (7)
280 .\" System V semantics are also provided if one uses the separate
281 .\" .BR sysv_signal (3)
284 Linux ¤Î libc4 ¤È libc5 ¤Î
286 ´Ø¿ô¤Ï System V Êý¼°¤Ç¤¢¤ë¡£
287 libc5 ¥·¥¹¥Æ¥à¤Ë¤ª¤¤¤Æ
291 ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤È¡¢
311 .BR siginterrupt (3),