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
47 .\"WORD: signal handler シグナル・ハンドラ
48 .\"WORD: library ライブラリ
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
85 プログラマが定義した関数 (「シグナル・ハンドラ」) のアドレスの
90 がプロセスに配送されると、以下のいずれかが発生する。
95 に設定されている場合、そのシグナルは無視される。
100 に設定されている場合、シグナルに関連づけられた
109 にリセットされるかそのシグナルのブロックが実行された後、
114 ハンドラが起動される際にシグナルがブロックされた場合、
115 ハンドラが返る際にそのシグナルのブロックが解除される。
124 は、今までのシグナル・ハンドラの値を返す。エラーの場合は
133 C89, C99, POSIX.1-2001.
147 シグナルを無視した後の動作は未定義である。
148 0 による整数割り算の結果は未定義となる。
155 このシグナルを無視すると無限ループに陥るかもしれない。
164 シグナル・ハンドラ内から安全に呼び出すことができる、
165 async-signal-safe functions (非同期シングルで安全な関数) の
172 各種バージョンの libc でこの型は定義済みである;
189 .BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);"
203 (POSIX.1 は明示的にこの違いを認めている)。
204 .B "移植性が必要なときはこのシステムコールを使用しないこと。"
208 を規定することで移植性に関する混乱を解決した。
210 はシグナル・ハンドラが起動される際の挙動を明示的に制御できる。
212 の代わりにこのインターフェイスを使うこと。
216 を使って設定されたハンドラがシグナルの配送により起動されると、
219 にリセットされ、システムは同じシグナルがさらに生成されても
224 こうした挙動はまずく、ハンドラがハンドラ自身を再設定する機会が
225 来るより前に、同じシグナルがまた配送される可能性がある。
226 さらに、同じシグナルが立て続けに配送されると、同じシグナルが
229 BSD では、シグナル処理の挙動を変更することで、この状況を改善した
232 を使ってハンドラを設定する際に挙動が黙って変更される)。
233 BSD では、シグナルハンドラが起動された際、
235 ハンドラの実行中は、同じシグナルのさらなる生成は配送がブロックされる。
241 システムコールは System V 方式を提供している。
243 デフォルトでは、glibc 2 以降では、
245 ラッパー関数はカーネルのシステムコールを起動しない。
246 代わりに、ラッパー関数は BSD 方式を示すフラグを使って
251 を定義していれば、このデフォルトの動作となる。
258 が定義された場合には暗黙のうちに定義され、
268 .RI ( -std=xxx " or " -ansi )
273 といった他の様々な機能検査マクロが定義された場合、
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 の
311 .BR siginterrupt (3),