OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[linuxjm/LDP_man-pages.git] / release / man2 / sigaction.2
1 .\" t
2 .\" Copyright (c) 1994,1995 Mike Battersby <mib@deakin.edu.au>
3 .\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" based on work by faith@cs.unc.edu
5 .\"
6 .\" %%%LICENSE_START(VERBATIM)
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" %%%LICENSE_END
27 .\"
28 .\" Modified, aeb, 960424
29 .\" Modified Fri Jan 31 17:31:20 1997 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified Thu Nov 26 02:12:45 1998 by aeb - add SIGCHLD stuff.
31 .\" Modified Sat May  8 17:40:19 1999 by Matthew Wilcox
32 .\"     add POSIX.1b signals
33 .\" Modified Sat Dec 29 01:44:52 2001 by Evan Jones <ejones@uwaterloo.ca>
34 .\"     SA_ONSTACK
35 .\" Modified 2004-11-11 by Michael Kerrisk <mtk.manpages@gmail.com>
36 .\"     Added mention of SIGCONT under SA_NOCLDSTOP
37 .\"     Added SA_NOCLDWAIT
38 .\" Modified 2004-11-17 by Michael Kerrisk <mtk.manpages@gmail.com>
39 .\"     Updated discussion for POSIX.1-2001 and SIGCHLD and sa_flags.
40 .\"     Formatting fixes
41 .\" 2004-12-09, mtk, added SI_TKILL + other minor changes
42 .\" 2005-09-15, mtk, split sigpending(), sigprocmask(), sigsuspend()
43 .\"     out of this page into separate pages.
44 .\" 2010-06-11 Andi Kleen, add hwpoison signal extensions
45 .\" 2010-06-11 mtk, improvements to discussion of various siginfo_t fields.
46 .\"
47 .\"*******************************************************************
48 .\"
49 .\" This file was generated with po4a. Translate the source file.
50 .\"
51 .\"*******************************************************************
52 .TH SIGACTION 2 2013\-02\-12 Linux "Linux Programmer's Manual"
53 .SH 名前
54 sigaction \- シグナルの動作の確認と変更
55 .SH 書式
56 .nf
57 \fB#include <signal.h>\fP
58 .sp
59 \fBint sigaction(int \fP\fIsignum\fP\fB, const struct sigaction *\fP\fIact\fP\fB,\fP
60 \fB              struct sigaction *\fP\fIoldact\fP\fB);\fP
61 .fi
62 .sp
63 .in -4n
64 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
65 .in
66 .sp
67 .ad l
68 \fBsigaction\fP(): _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
69
70 \fIsiginfo_t\fP: _POSIX_C_SOURCE >= 199309L
71 .ad b
72 .SH 説明
73 \fBsigaction\fP()  システムコールは、特定のシグナルを受信した際の プロセスの動作を変更するのに使用される (シグナルの概要については
74 \fBsignal\fP(7)  を参照)。
75 .PP
76 \fIsignum\fP には、 \fBSIGKILL\fP と \fBSIGSTOP\fP 以外の有効なシグナルをどれでも指定できる。
77 .PP
78 \fIact\fP が NULL 以外であれば、シグナル \fIsignum\fP の新しい動作 (action) として \fIact\fP が設定される。
79 \fIoldact\fP が NULL でなければ、今までの動作が \fIoldact\fP に格納される。
80 .PP
81 \fIsigaction\fP 構造体は以下のような感じに定義される。
82 .sp
83 .in +4n
84 .nf
85 struct sigaction {
86     void     (*sa_handler)(int);
87     void     (*sa_sigaction)(int, siginfo_t *, void *);
88     sigset_t   sa_mask;
89     int        sa_flags;
90     void     (*sa_restorer)(void);
91 };
92 .fi
93 .in
94 .PP
95 アーキテクチャによっては共用体 (union) が用いられており、その場合には \fIsa_handler\fP と \fIsa_sigaction\fP
96 の両方を同時に割り当てることはできない。
97 .PP
98 \fIsa_restorer\fP 要素は廃止予定であり使用すべきではない。 POSIX には \fIsa_restorer\fP 要素に関する規定はない。
99 .PP
100 \fIsa_handler\fP は \fIsignum\fP に対応する動作を指定するもので、 デフォルトの動作を行う \fBSIG_DFL\fP、
101 そのシグナルを無視する \fBSIG_IGN\fP、 シグナルハンドラ関数へのポインタが設定できる。
102 シグナルハンドラ関数の引き数は一つであり、シグナル番号が引き数として 渡される。
103 .PP
104 If \fBSA_SIGINFO\fP is specified in \fIsa_flags\fP, then \fIsa_sigaction\fP (instead
105 of \fIsa_handler\fP)  specifies the signal\-handling function for \fIsignum\fP.
106 This function receives the signal number as its first argument, a pointer to
107 a \fIsiginfo_t\fP as its second argument and a pointer to a \fIucontext_t\fP (cast
108 to \fIvoid\ *\fP) as its third argument.  (Commonly, the handler function
109 doesn't make any use of the third argument.  See \fBgetcontext\fP(3)  for
110 further information about \fIucontext_t\fP.)
111 .PP
112 \fIsa_mask\fP は、シグナル・ハンドラ実行中に禁止 (block) すべきシグナルのマスクを指定する
113 (ハンドラ実行中のシグナルの禁止は、シグナル・ハンドラが起動されたスレッド のシグナルのマスクに追加することで行われる)。 さらに、
114 \fBSA_NODEFER\fP フラグが指定されていない場合は、ハンドラを起動するきっかけとなる シグナルにも \fIsa_mask\fP が適用される。
115 .PP
116 \fIsa_flags\fP はシグナル・ハンドラの動作を変更するためのフラグの集合を指定する。 \fIsa_flags\fP には、以下に示すフラグの (0
117 個以上の) 論理和をとったものを指定する。
118 .RS 4
119 .TP 
120 \fBSA_NOCLDSTOP\fP
121 \fIsignum\fP が \fBSIGCHLD\fP の場合、 子プロセスが停止したり (子プロセスが \fBSIGSTOP\fP, \fBSIGTSTP\fP,
122 \fBSIGTTIN\fP, \fBSIGTTOU\fP を受けたとき) 再開したり (子プロセスが \fBSIGCONT\fP を受けたとき) したときに
123 \fBSIGCHLD\fP の通知を受けない。 このフラグは、 \fBSIGCHLD\fP に対してハンドラを設定する際にのみ意味を持つ。
124 .TP 
125 \fBSA_NOCLDWAIT\fP (Linux 2.6 以降)
126 .\" To be precise: Linux 2.5.60 -- MTK
127 (Linux 2.6 以降)  \fIsignum\fP が \fBSIGCHLD\fP の場合、子プロセスが終了したときに
128 子プロセスをゾンビプロセスに変化させない (\fBwaitpid\fP(2)  も参照)。 このフラグは、 \fBSIGCHLD\fP
129 に対してハンドラを設定する際、もしくはそのシグナルの処理方法を \fBSIG_DFL\fP に設定する際にのみ意味を持つ。
130
131 \fBSIGCHLD\fP に対してハンドラを設定する際に \fBSA_NOCLDWAIT\fP フラグをセットした場合、 子プロセスが終了した際に
132 \fBSIGCHLD\fP シグナルが生成されるかどうかは、 POSIX.1 では規定されていない。 Linux では、この状況で \fBSIGCHLD\fP
133 シグナルは生成される。 いくつかの他の実装では生成されない。
134 .TP 
135 \fBSA_NODEFER\fP
136 それ自身のシグナル・ハンドラーの内部にいる時でも そのシグナルをマスクしないようにする。 このフラグはシグナルハンドラを設定する際にのみ意味を持つ。
137 \fBSA_NOMASK\fP はこのフラグと同じ意味だが、廃止されており、非標準である。
138 .TP 
139 \fBSA_ONSTACK\fP
140 \fBsigaltstack\fP(2)  で提供される別のシグナル・スタックでシグナルハンドラを呼び出す。
141 別のシグナル・スタックが利用可能でなければ、デフォルトのスタックが 使用される。 このフラグはシグナルハンドラを設定する際にのみ意味を持つ。
142 .TP 
143 \fBSA_RESETHAND\fP
144 Restore the signal action to the default upon entry to the signal handler.
145 This flag is only meaningful when establishing a signal handler.
146 \fBSA_ONESHOT\fP is an obsolete, nonstandard synonym for this flag.
147 .TP 
148 \fBSA_RESTART\fP
149 いくつかのシステムコールをシグナルの通知の前後で再開できるようにして、 BSD シグナル方式 (semantics) と互換性のある動作を提供する。
150 このフラグはシグナルハンドラを設定する際にのみ意味を持つ。 \fBsignal\fP(7)  に書かれているシステムコールの再開に関する議論を参照のこと。
151 .TP 
152 \fBSA_SIGINFO\fP (Linux 2.2 以降)
153 .\" (The
154 .\" .I sa_sigaction
155 .\" field was added in Linux 2.1.86.)
156 The signal handler takes three arguments, not one.  In this case,
157 \fIsa_sigaction\fP should be set instead of \fIsa_handler\fP.  This flag is only
158 meaningful when establishing a signal handler.
159 .RE
160 .PP
161 \fIsa_sigaction\fP のパラメータ \fIsiginfo_t\fP は以下の要素を持つ構造体である:
162 .sp
163 .in +4n
164 .nf
165 .\" FIXME
166 .\" si_trapno seems to be only used on SPARC and Alpha;
167 .\" this page could use a little more detail on its purpose there.
168 .\" In the kernel: si_tid
169 siginfo_t {
170     int      si_signo;    /* Signal number */
171     int      si_errno;    /* An errno value */
172     int      si_code;     /* Signal code */
173     int      si_trapno;   /* Trap number that caused
174                              hardware\-generated signal
175                              (unused on most architectures) */
176     pid_t    si_pid;      /* Sending process ID */
177     uid_t    si_uid;      /* Real user ID of sending process */
178     int      si_status;   /* Exit value or signal */
179     clock_t  si_utime;    /* User time consumed */
180     clock_t  si_stime;    /* System time consumed */
181     sigval_t si_value;    /* Signal value */
182     int      si_int;      /* POSIX.1b signal */
183     void    *si_ptr;      /* POSIX.1b signal */
184     int      si_overrun;  /* Timer overrun count; POSIX.1b timers */
185     int      si_timerid;  /* Timer ID; POSIX.1b timers */
186     void    *si_addr;     /* Memory location which caused fault */
187     long     si_band;     /* Band event (was \fIint\fP in
188                              glibc 2.3.2 and earlier) */
189     int      si_fd;       /* File descriptor */
190     short    si_addr_lsb; /* Least significant bit of address
191                              (since kernel 2.6.32) */
192 }
193 .fi
194 .in
195
196 \fIsi_signo\fP, \fIsi_errno\fP, \fIsi_code\fP は全てのシグナルに対して定義されている (\fIsi_errno\fP は
197 Linux では一般的には使用されない)。 構造体の残りの部分は、共用体 (union) になっているかもしれない。
198 その場合は該当するシグナルにおいて意味のあるフィールドのみを読み込む ことができる。
199 .IP * 2
200 Signals sent with \fBkill\fP(2)  and \fBsigqueue\fP(3)  fill in \fIsi_pid\fP and
201 \fIsi_uid\fP.  In addition, signals sent with \fBsigqueue\fP(3)  fill in \fIsi_int\fP
202 and \fIsi_ptr\fP with the values specified by the sender of the signal; see
203 \fBsigqueue\fP(3)  for more details.
204 .IP *
205 POSIX.1b タイマ (Linux 2.6 以降) は \fIsi_overrun\fP と \fIsi_timerid\fP を
206 設定する。 \fIsi_timerid\fP フィールドはカーネルがタイマを特定するのに
207 使用する内部 ID であり、 \fBtimer_create\fP(2) が返すタイマ ID と同じではない。
208 \fIsi_overrun\fP フィールドはタイマが回り切った回数である。
209 これは \fBtimer_getoverrun\fP(2) の呼び出しで取得できる情報と同じである。
210 これらのフィールドは非標準で Linux による拡張である。
211 .IP *
212 Signals sent for message queue notification (see the description of
213 \fBSIGEV_SIGNAL\fP in \fBmq_notify\fP(3))  fill in \fIsi_int\fP/\fIsi_ptr\fP, with the
214 \fIsigev_value\fP supplied to \fBmq_notify\fP(3); \fIsi_pid\fP, with the process ID
215 of the message sender; and \fIsi_uid\fP, with the real user ID of the message
216 sender.
217 .IP *
218 .\" FIXME .
219 .\" When si_utime and si_stime where originally implemented, the
220 .\" measurement unit was HZ, which was the same as clock ticks
221 .\" (sysconf(_SC_CLK_TCK)).  In 2.6, HZ became configurable, and
222 .\" was *still* used as the unit to return the info these fields,
223 .\" with the result that the field values depended on the the
224 .\" configured HZ.  Of course, the should have been measured in
225 .\" USER_HZ instead, so that sysconf(_SC_CLK_TCK) could be used to
226 .\" convert to seconds.  I have a queued patch to fix this:
227 .\" http://thread.gmane.org/gmane.linux.kernel/698061/ .
228 .\" This patch made it into 2.6.27.
229 .\" But note that these fields still don't return the times of
230 .\" waited-for children (as is done by getrusage() and times()
231 .\" and wait4()).  Solaris 8 does include child times.
232 \fBSIGCHLD\fP は \fIsi_pid\fP, \fIsi_uid\fP, \fIsi_status\fP, \fIsi_utime\fP,
233 \fIsi_stime\fP を設定し、子プロセスに関する情報を提供する。
234 \fIsi_pid\fP フィールドは子プロセスのプロセス ID で、
235 \fIsi_uid\fP フィールドは子プロセスの実ユーザ ID である。
236 \fIsi_stime\fP フィールドには、 (\fIsi_code\fP が \fBCLD_EXITED\fP の場合は)
237 子プロセスの終了ステータスが、それ以外の場合は状態が変化する原因と
238 なったシグナル番号が格納される。
239 \fIsi_utime\fP と \fIsi_stime\fP には子プロセスが使用したユーザ CPU 時間とシ
240 ステム CPU 時間がそれぞれ格納される。(\fBgetrusage\fP(2) や \fBtime\fP(2) と
241 異なり) これらのフィールドには wait 待ちの子プロセスにより使用された時
242 間は含まれない。 2.6 より前と 2.6.27 以降のカーネルでは、 これらのフィー
243 ルドに格納される CPU 時間の単位は \fIsysconf(_SC_CLK_TCK)\fP である。
244 2.6.27 より前の 2.6 系のカーネルでは、バグがあり、 これらのフィールドの
245 CPU 時間の単位が (カーネルのコンフィグで指定される) システムの jiffy で
246 あった (\fBtime\fP(7) 参照)。
247 .IP *
248 .\" FIXME SIGTRAP also sets the following for ptrace_notify() ?
249 .\"     info.si_code = exit_code;
250 .\"     info.si_pid = task_pid_vnr(current);
251 .\"     info.si_uid = current_uid();  /* Real UID */
252 \fBSIGILL\fP, \fBSIGFPE\fP, \fBSIGSEGV\fP, \fBSIGBUS\fP, and \fBSIGTRAP\fP fill in
253 \fIsi_addr\fP with the address of the fault.  On some architectures, these
254 signals also fill in the \fIsi_trapno\fP filed.  Some suberrors of \fBSIGBUS\fP,
255 in particular \fBBUS_MCEERR_AO\fP and \fBBUS_MCEERR_AR\fP, also fill in
256 \fIsi_addr_lsb\fP.  This field indicates the least significant bit of the
257 reported address and therefore the extent of the corruption.  For example,
258 if a full page was corrupted, \fIsi_addr_lsb\fP contains
259 \fIlog2(sysconf(_SC_PAGESIZE))\fP.  \fBBUS_MCERR_*\fP and \fIsi_addr_lsb\fP are
260 Linux\-specific extensions.
261 .IP *
262 \fBSIGIO\fP/\fBSIGPOLL\fP (the two names are synonyms on Linux)  fills in
263 \fIsi_band\fP and \fIsi_fd\fP.  The \fIsi_band\fP event is a bit mask containing the
264 same values as are filled in the \fIrevents\fP field by \fBpoll\fP(2).  The
265 \fIsi_fd\fP field indicates the file descriptor for which the I/O event
266 occurred.
267 .PP
268 \fIsi_code\fP は、そのシグナルが送信された理由を示す値である (ビットマスクではない)。 以下のリストに、どのシグナルの場合でも
269 \fIsi_code\fP に入りうる値を、シグナルが生成された理由とともに記載する。
270 .RS 4
271 .TP  15
272 \fBSI_USER\fP
273 \fBkill\fP(2)
274 .TP 
275 \fBSI_KERNEL\fP
276 カーネルにより送信された
277 .TP 
278 \fBSI_QUEUE\fP
279 \fBsigqueue\fP(3)
280 .TP 
281 \fBSI_TIMER\fP
282 POSIX タイマが満了した
283 .TP 
284 \fBSI_MESGQ\fP
285 POSIX メッセージキューの状態が変化した (Linux 2.6.6 以降)。 \fBmq_notify\fP(3)\fB参照。\fP
286 .TP 
287 \fBSI_ASYNCIO\fP
288 非同期 IO (AIO) が完了した
289 .TP 
290 \fBSI_SIGIO\fP
291 Queued \fBSIGIO\fP (only in kernels up to Linux 2.2; from Linux 2.4 onward
292 \fBSIGIO\fP/\fBSIGPOLL\fP fills in \fIsi_code\fP as described below).
293 .TP 
294 \fBSI_TKILL\fP
295 .\" SI_DETHREAD is defined in 2.6.9 sources, but isn't implemented
296 .\" It appears to have been an idea that was tried during 2.5.6
297 .\" through to 2.5.24 and then was backed out.
298 \fBtkill\fP(2)  または \fBtgkill\fP(2)  (Linux 2.4.19 以降)
299 .RE
300 .PP
301 \fBSIGILL\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
302 .RS 4
303 .TP  15
304 \fBILL_ILLOPC\fP
305 不正な命令コード (opcode)
306 .TP 
307 \fBILL_ILLOPN\fP
308 不正なオペランド
309 .TP 
310 \fBILL_ILLADR\fP
311 不正なアドレッシングモード
312 .TP 
313 \fBILL_ILLTRP\fP
314 不正なトラップ
315 .TP 
316 \fBILL_PRVOPC\fP
317 特権が必要な命令コード (opcode)
318 .TP 
319 \fBILL_PRVREG\fP
320 特権が必要なレジスタ
321 .TP 
322 \fBILL_COPROC\fP
323 コプロセッサのエラー
324 .TP 
325 \fBILL_BADSTK\fP
326 内部スタックエラー
327 .RE
328 .PP
329 \fBSIGFPE\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
330 .RS 4
331 .TP  15
332 \fBFPE_INTDIV\fP
333 整数の 0 による除算
334 .TP 
335 \fBFPE_INTOVF\fP
336 整数のオーバーフロー
337 .TP 
338 \fBFPE_FLTDIV\fP
339 浮動小数点の 0 による除算
340 .TP 
341 \fBFPE_FLTOVF\fP
342 浮動小数点のオーバーフロー
343 .TP 
344 \fBFPE_FLTUND\fP
345 浮動小数点のアンダーフロー
346 .TP 
347 \fBFPE_FLTRES\fP
348 浮動小数点の不正確な演算結果 (inexact result)
349 .TP 
350 \fBFPE_FLTINV\fP
351 浮動小数点の不正な操作
352 .TP 
353 \fBFPE_FLTSUB\fP
354 範囲外の添字 (subscript)
355 .RE
356 .PP
357 \fBSIGSEGV\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
358 .RS 4
359 .TP  15
360 \fBSEGV_MAPERR\fP
361 オブジェクトにマッピングされていないアドレス
362 .TP 
363 \fBSEGV_ACCERR\fP
364 マッピングされたオブジェクトに対するアクセス許可がない
365 .RE
366 .PP
367 \fBSIGBUS\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
368 .RS 4
369 .TP  15
370 \fBBUS_ADRALN\fP
371 不正なアドレス・アライメント (alignment)
372 .TP 
373 \fBBUS_ADRERR\fP
374 存在しない物理アドレス
375 .TP 
376 \fBBUS_OBJERR\fP
377 オブジェクト固有のハードウェアエラー
378 .TP 
379 \fBBUS_MCEERR_AR\fP (Linux 2.6.32 以降)
380 Hardware memory error consumed on a machine check; action required.
381 .TP 
382 \fBBUS_MCEERR_AO\fP (Linux 2.6.32  以降)
383 Hardware memory error detected in process but not consumed; action optional.
384 .RE
385 .PP
386 \fBSIGTRAP\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
387 .RS 4
388 .TP  15
389 \fBTRAP_BRKPT\fP
390 プロセスのブレークポイント
391 .TP 
392 \fBTRAP_TRACE\fP
393 プロセスのトレース・トラップ
394 .TP 
395 \fBTRAP_BRANCH\fP (Linux 2.4 以降)
396 process taken branch trap
397 .TP 
398 \fBTRAP_HWBKPT\fP (Linux 2.4 以降)
399 hardware breakpoint/watchpoint
400 .RE
401 .PP
402 \fBSIGCHLD\fP シグナルの場合、 \fIsi_code\fP には以下の値を指定できる:
403 .RS 4
404 .TP  15
405 \fBCLD_EXITED\fP
406 子プロセスが終了した (exited)
407 .TP 
408 \fBCLD_KILLED\fP
409 子プロセスが kill された
410 .TP 
411 \fBCLD_DUMPED\fP
412 子プロセスが異常終了した
413 .TP 
414 \fBCLD_TRAPPED\fP
415 トレース対象の子プロセスがトラップを上げた
416 .TP 
417 \fBCLD_STOPPED\fP
418 子プロセスが停止 (stop) した
419 .TP 
420 \fBCLD_CONTINUED\fP
421 停止していた子プロセスが再開した (Linux 2.6.9 以降)
422 .RE
423 .PP
424 \fBSIGIO\fP/\fBSIGPOLL\fP シグナルの場合、 \fIsi_code\fP には以下の値を
425 指定できる:
426 .RS 4
427 .TP  15
428 \fBPOLL_IN\fP
429 入力データが利用可能
430 .TP 
431 \fBPOLL_OUT\fP
432 出力バッファが利用可能
433 .TP 
434 \fBPOLL_MSG\fP
435 入力メッセージが利用可能
436 .TP 
437 \fBPOLL_ERR\fP
438 I/O エラー
439 .TP 
440 \fBPOLL_PRI\fP
441 高優先の入力が利用可能
442 .TP 
443 \fBPOLL_HUP\fP
444 デバイスが接続されていない
445 .RE
446 .SH 返り値
447 \fBsigaction\fP()  は成功すれば 0 を返し、エラーならば \-1 を返す。
448 .SH エラー
449 .TP 
450 \fBEFAULT\fP
451 \fIact\fP か \fIoldact\fP が指しているメモリが正しいプロセスのアドレス空間にない。
452 .TP 
453 \fBEINVAL\fP
454 無効なシグナルが指定された。補足 (catch) したり無視したりできない シグナルである \fBSIGKILL\fP や \fBSIGSTOP\fP
455 に対する動作を変更しようとした場合にも発生する。
456 .SH 準拠
457 .\" SVr4 does not document the EINTR condition.
458 POSIX.1\-2001, SVr4.
459 .SH 注意
460 \fBfork\fP(2) 経由で作成された子プロセスは、親プロセスのシグナルの処理方法の コピーを継承する。
461 \fBexecve\fP(2) の前後で、ハンドラが設定されているシグナルの処理方法はデフォルトにリセットされ、
462 無視が設定されているシグナルの処理方法は変更されずそのままとなる。
463
464 POSIX では、 \fBkill\fP(2)  や \fBraise\fP(3)  で生成できないシグナル \fBSIGFPE\fP, \fBSIGILL\fP,
465 \fBSIGSEGV\fP を無視 (ignore) した場合、その後の動作は未定義である。 ゼロによる整数割り算の結果は未定義となる。
466 アーキテクチャーによっては、このとき \fBSIGFPE\fP シグナルが生成される。 (同様に負の最大整数を \-1 で割ると \fBSIGFPE\fP
467 が生成されるかもしれない)  このシグナルを無視すると無限ループに陥るかもしれない。
468 .PP
469 POSIX.1\-1990 では \fBSIGCHLD\fP に \fBSIG_IGN\fP を設定することを認めていない。 POSIX.1\-2001
470 では認められており、 \fBSIGCHLD\fP を無視することでゾンビプロセスの生成を防止することができる (\fBwait\fP(2)  を参照)。
471 さらに、BSD と SystemV では \fBSIGCHLD\fP を無視した際の動作が異なっている。
472 そのため、完全に移植性がある方法で、終了した子プロセスがゾンビにならないこと を保証するには、 \fBSIGCHLD\fP シグナルを補足し、
473 \fBwait\fP(2)  などを実行するしかない。
474 .PP
475 POSIX.1\-1990 の仕様では \fBSA_NOCLDSTOP\fP のみが定義されている。
476 POSIX.1\-2001 では \fBSA_NOCLDWAIT\fP, \fBSA_RESETHAND\fP, \fBSA_NODEFER\fP,
477 \fBSA_SIGINFO\fP が追加された。 UNIX の古い実装で動かすアプリケーションで、
478 他の \fIsa_flags\fP フラグを使用すると移植性が下がる。
479 .PP
480 \fBSA_RESETHAND\fP フラグは SVr4 の同じ名前のフラグと互換性がある。
481 .PP
482 \fBSA_NODEFER\fP フラグは 1.3.9 以降のカーネルでは同じ名前の SVr4 のフラグと互換性がある。 ぞれ以前の Linux
483 カーネルの実装では、このフラグを設定しているシグナル だけでなく、どのシグナルでも受けることを許していた (実際には \fIsa_mask\fP
484 の設定により無効にできる)。
485 .PP
486 \fBsigaction\fP()  の二番目の引き数に NULL を指定して呼び出すと、現在のシグナルハンドラを確認する
487 ことができる。また、二番目と三番目の引き数を NULL にて呼び出すことで、 指定されたシグナルが現在のマシンで使えるかどうかチェックできる。
488 .PP
489 \fBSIGKILL\fP や \fBSIGSTOP\fP を (\fIsa_mask\fP に指定して) 禁止することはできない。 禁止しようとしても黙って無視される。
490 .PP
491 シグナル集合の操作に関する詳細は \fBsigsetops\fP(3)  を参照のこと。
492 .PP
493 シグナルハンドラ内から安全に呼び出すことができる、 async\-signal\-safe functions (非同期シングルで安全な関数) の
494 リストについては \fBsignal\fP(7)  を参照。
495 .SS 非公式
496 Before the introduction of \fBSA_SIGINFO\fP it was also possible to get some
497 additional information, namely by using a \fIsa_handler\fP with second argument
498 of type \fIstruct sigcontext\fP.  See the relevant Linux kernel sources for
499 details.  This use is obsolete now.
500 .SH バグ
501 2.6.13 以前のカーネルでは、 \fIsa_flags\fP に \fBSA_NODEFER\fP を指定した場合、
502 ハンドラが実行中に配送されたシグナル自身がマスクされなくなるだけでなく、 \fIsa_mask\fP に指定されたシグナルもマスクされなくなる。
503 このバグは、カーネル 2.6.14 で修正された。
504 .SH 例
505 \fBmprotect\fP(2)  参照。
506 .SH 関連項目
507 \fBkill\fP(1), \fBkill\fP(2), \fBkillpg\fP(2), \fBpause\fP(2), \fBsigaltstack\fP(2),
508 \fBsignal\fP(2), \fBsignalfd\fP(2), \fBsigpending\fP(2), \fBsigprocmask\fP(2),
509 \fBsigsuspend\fP(2), \fBwait\fP(2), \fBraise\fP(3), \fBsiginterrupt\fP(3),
510 \fBsigqueue\fP(3), \fBsigsetops\fP(3), \fBsigvec\fP(3), \fBcore\fP(5),
511 \fBsignal\fP(7)
512 .SH この文書について
513 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
514 である。プロジェクトの説明とバグ報告に関する情報は
515 http://www.kernel.org/doc/man\-pages/ に書かれている。