2 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" and Copyright (c) 2002, 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
5 .\" <mtk.manpages@gmail.com>
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.
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.
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
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified Sat Jul 24 17:34:08 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Sun Jan 7 01:41:27 1996 by Andries Brouwer (aeb@cwi.nl)
29 .\" Modified Sun Apr 14 12:02:29 1996 by Andries Brouwer (aeb@cwi.nl)
30 .\" Modified Sat Nov 13 16:28:23 1999 by Andries Brouwer (aeb@cwi.nl)
31 .\" Modified 10 Apr 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
32 .\" Modified 7 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Added information on real-time signals
34 .\" Modified 13 Jun 2002, by Michael Kerrisk <mtk.manpages@gmail.com>
35 .\" Noted that SIGSTKFLT is in fact unused
36 .\" 2004-12-03, Modified mtk, added notes on RLIMIT_SIGPENDING
37 .\" 2006-04-24, mtk, Added text on changing signal dispositions,
38 .\" signal mask, and pending signals.
40 .\" Added section on system call restarting (SA_RESTART)
41 .\" Added section on stop/cont signals interrupting syscalls.
42 .\" 2008-10-05, mtk: various additions
44 .\" Japanese Version Copyright (c) 1997 Takafumi Naka
45 .\" and 2005-2008 Akihiro MOTOKI
46 .\" all rights reserved.
47 .\" Translated 1997-02-13, Takafumi Naka <takafumi@yk.rim.or.jp>
48 .\" Modified 1999-06-22, Tatsuo SEKINE <tsekine@isoternet.org>
49 .\" Modified 1999-07-18, Takafumi Naka <takafumi@yk.rim.or.jp>
50 .\" Modified 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>, LDP v1.28
51 .\" Updated 2003-07-24, Kentaro Shirakata <argrath@ub32.org>
52 .\" Updated 2005-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
53 .\" Updated 2006-07-28, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
54 .\" Updated 2007-05-28, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.50
55 .\" Updated 2007-09-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
56 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
57 .\" Updated 2008-11-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
58 .\" Updated 2010-04-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
60 .\"WORD: disposition 処理方法
62 .\"WORD: signal handler シグナルハンドラ
64 .TH SIGNAL 7 2011-09-18 "Linux" "Linux Programmer's Manual"
66 .\"O signal \- overview of signals
71 .\"O Linux supports both POSIX reliable signals (hereinafter
72 .\"O "standard signals") and POSIX real-time signals.
73 Linux は POSIX 信頼シグナル (reliable signal; 以後 "標準シグナル"と表記)
74 と POSIX リアルタイムシグナルの両方に対応している。
75 .\"O .SS "Signal Dispositions"
77 .\"O Each signal has a current
78 .\"O .IR disposition ,
79 .\"O which determines how the process behaves when it is delivered
81 シグナルはそれぞれ現在の「処理方法 (disposition)」を保持しており、
82 この処理方法によりシグナルが配送された際にプロセスが
85 .\"O The entries in the "Action" column of the tables below specify
86 .\"O the default disposition for each signal, as follows:
87 後述の表の "動作" の欄のエントリは各シグナルのデフォルトの
88 処理方法を示しており、以下のような意味を持つ。
90 .\"O Default action is to terminate the process.
93 .\"O Default action is to ignore the signal.
96 .\"O Default action is to terminate the process and dump core (see
98 デフォルトの動作はプロセス終了とコアダンプ出力
102 .\"O Default action is to stop the process.
105 .\"O Default action is to continue the process if it is currently stopped.
106 デフォルトの動作は、プロセスが停止中の場合にその実行の再開。
108 .\"O A process can change the disposition of a signal using
109 .\"O .BR sigaction (2)
112 .\"O (The latter is less portable when establishing a signal handler;
120 を使って、シグナルの処理方法を変更することができる
122 の方がシグナルハンドラを設定する際の移植性が低い;
126 .\"O Using these system calls, a process can elect one of the
127 .\"O following behaviors to occur on delivery of the signal:
128 .\"O perform the default action; ignore the signal;
129 .\"O or catch the signal with a
130 .\"O .IR "signal handler" ,
131 .\"O a programmer-defined function that is automatically invoked
132 .\"O when the signal is delivered.
133 .\"O (By default, the signal handler is invoked on the
134 .\"O normal process stack.
135 .\"O It is possible to arrange that the signal handler
136 .\"O uses an alternate stack; see
137 .\"O .BR sigaltstack (2)
138 .\"O for a discussion of how to do this and when it might be useful.)
140 プロセスが選択できるのは、次のいずれか一つである。
141 デフォルトの動作を実行する、シグナルを無視する、
142 .I "シグナルハンドラ (signal handler)"
143 でシグナルを捕捉する。シグナルハンドラとは、シグナル配送時に
144 自動的に起動されるプログラマ定義の関数である。
145 (デフォルトでは、シグナルハンドラは通常のプロセスのスタック上で起動される。
146 シグナルハンドラが代替スタック (alternate stack) を使用するように設定する
147 こともできる。代替スタックを使用するように設定する方法と、どのような際に
148 代替スタックが役に立つかについての議論については
152 .\"O The signal disposition is a per-process attribute:
153 .\"O in a multithreaded application, the disposition of a
154 .\"O particular signal is the same for all threads.
155 シグナルの処理方法はプロセス単位の属性である。
156 マルチスレッドのアプリケーションでは、あるシグナルの処理方法は
159 .\"O A child created via
161 .\"O inherits a copy of its parent's signal dispositions.
164 .\"O the dispositions of handled signals are reset to the default;
165 .\"O the dispositions of ignored signals are left unchanged.
167 で作成された子プロセスは親プロセスのシグナルの処理方法のコピーを継承する。
169 の間、ハンドラが登録されているシグナルの処理方法はデフォルトにリセット
170 され、無視となっているシグナルの処理方法は変更されずそのままとなる。
171 .\"O .SS Sending a Signal
173 .\"O The following system calls and library functions allow
174 .\"O the caller to send a signal:
175 以下のシステムコールとライブラリ関数を使って、
176 呼び出し者はシグナルを送信することができる。
179 .\"O Sends a signal to the calling thread.
183 .\"O Sends a signal to a specified process,
184 .\"O to all members of a specified process group,
185 .\"O or to all processes on the system.
186 指定されたプロセスや、指定されたプロセスグループの全メンバー、
190 .\"O Sends a signal to all of the members of a specified process group.
191 指定されたプロセスグループの全メンバーにシグナルを送る。
194 .\"O Sends a signal to a specified POSIX thread in the same process as
196 呼び出し者と同じプロセス内の指定された POSIX スレッドにシグナルを送る。
199 .\"O Sends a signal to a specified thread within a specific process.
200 .\"O (This is the system call used to implement
201 .\"O .BR pthread_kill (3).)
202 指定されたプロセス内の指定されたスレッドにシグナルを送る
208 .\"O Sends a real-time signal with accompanying data to a specified process.
209 指定されたプロセスに付属データとともにリアルタイムシグナルを送る。
210 .\"O .SS Waiting for a Signal to be Caught
212 .\"O The following system calls suspend execution of the calling process
213 .\"O or thread until a signal is caught
214 .\"O (or an unhandled signal terminates the process):
215 以下のシステムコールを使って、シグナルが捕捉されるまで
216 呼び出したプロセスやスレッドの実行を中断 (suspend) することができる
217 (ハンドラが設定されていないシグナルによりそのプロセスが終了した
221 .\"O Suspends execution until any signal is caught.
222 何かシグナルが捕捉されるまで実行を停止する。
225 .\"O Temporarily changes the signal mask (see below) and suspends
226 .\"O execution until one of the unmasked signals is caught.
227 一時的にシグナルマスク (下記参照) を変更し、
228 マスクされていないシグナルのいずれかが捕捉されるまで
230 .\"O .SS Synchronously Accepting a Signal
232 .\"O Rather than asynchronously catching a signal via a signal handler,
233 .\"O it is possible to synchronously accept the signal, that is,
234 .\"O to block execution until the signal is delivered,
235 .\"O at which point the kernel returns information about the
236 .\"O signal to the caller.
237 .\"O There are two general ways to do this:
238 シグナルハンドラ経由でシグナルを非同期 (asynchronously) で捕捉する以外にも、
239 シグナルを同期 (synchronously) して受け付けることもできる。
240 同期して受け付けるとは、シグナルが配送されるまで実行を停止 (block)
241 するということである。シグナルを受け付けた際に、カーネルは
242 そのシグナルに関する情報を呼び出し者に返す。
245 .\"O .BR sigwaitinfo (2),
246 .\"O .BR sigtimedwait (2),
249 .\"O suspend execution until one of the signals in a specified
250 .\"O set is delivered.
251 .\"O Each of these calls returns information about the delivered signal.
253 .BR sigtimedwait (2),
255 は、指定されたシグナル集合のシグナルの一つが配送されるまで実行を中断する。
256 どのシステムコールや関数でも、配送されたシグナルに関する情報が返される。
258 .\"O .BR signalfd (2)
259 .\"O returns a file descriptor that can be used to read information
260 .\"O about signals that are delivered to the caller.
263 .\"O from this file descriptor blocks until one of the signals
264 .\"O in the set specified in the
265 .\"O .BR signalfd (2)
266 .\"O call is delivered to the caller.
267 .\"O The buffer returned by
269 .\"O contains a structure describing the signal.
271 が返すファイルディスクリプタを使うと、呼び出し元に配送された
272 シグナルに関する情報を読み出すことができる。
277 の呼び出し時に指定されたシグナル集合のシグナルの一つが呼び出し元に
278 配送されるまで停止 (block) する。
280 が返すバッファにはシグナルに関する情報を格納した構造体が入っている。
281 .\"O .SS "Signal Mask and Pending Signals"
285 .\"O which means that it will not be delivered until it is later unblocked.
286 .\"O Between the time when it is generated and when it is delivered
287 .\"O a signal is said to be
291 されることがある。ブロックされると、そのシグナルは
292 その後ブロックを解除されるまで配送されなくなる。
293 シグナルが生成されてから配送されるまでの間、そのシグナルは
297 .\"O Each thread in a process has an independent
298 .\"O .IR "signal mask" ,
299 .\"O which indicates the set of signals that the thread is currently blocking.
300 .\"O A thread can manipulate its signal mask using
301 .\"O .BR pthread_sigmask (3).
302 .\"O In a traditional single-threaded application,
303 .\"O .BR sigprocmask (2)
304 .\"O can be used to manipulate the signal mask.
306 .I "シグナルマスク (signal mask)"
307 を持つ。シグナルマスクはそのスレッドが現在ブロックしている
310 .BR pthread_sigmask (3)
311 を使って自分のシグナルマスクを操作できる。
312 伝統的なシングルスレッドのアプリケーションでは、
316 .\"O A child created via
318 .\"O inherits a copy of its parent's signal mask;
319 .\"O the signal mask is preserved across
323 親プロセスのシグナルマスクのコピーを継承する。
327 .\"O A signal may be generated (and thus pending)
328 .\"O for a process as a whole (e.g., when sent using
330 .\"O or for a specific thread (e.g., certain signals,
336 .\"O consequence of executing a specific machine-language instruction
337 .\"O are thread directed, as are signals targeted at a specific thread using
338 .\"O .BR pthread_kill (3)).
339 .\"O A process-directed signal may be delivered to any one of the
340 .\"O threads that does not currently have the signal blocked.
341 .\"O If more than one of the threads has the signal unblocked, then the
342 .\"O kernel chooses an arbitrary thread to which to deliver the signal.
343 生成されるシグナル (したがって処理待ちとなるシグナル) には、
344 プロセス全体宛てと特定のスレッド宛てがある。
348 特定のマシン語の命令の実行の結果として生成される、
355 を使って特定のスレッド宛てに生成されたシグナルも
357 プロセス宛てのシグナルは、そのシグナルをブロックしていないスレッドのうち
358 いずれかの一つに配送することができる。そのシグナルをブロックしていない
359 スレッドが複数ある場合、シグナルを配送するスレッドはカーネルが
362 .\"O A thread can obtain the set of signals that it currently has pending
364 .\"O .BR sigpending (2).
365 .\"O This set will consist of the union of the set of pending
366 .\"O process-directed signals and the set of signals pending for
367 .\"O the calling thread.
370 を使って、現在処理待ちのシグナル集合を取得することができる。
371 この集合は、プロセス宛ての処理待ちシグナルと
372 呼び出したスレッド宛てのシグナルの両方から構成される。
374 .\"O A child created via
376 .\"O initially has an empty pending signal set;
377 .\"O the pending signal set is preserved across an
380 経由で作成された子プロセスでは、処理待ちのシグナル集合は
383 の前後で、処理待ちのシグナル集合は保持される。
384 .\"O .SS "Standard Signals"
386 .\"O Linux supports the standard signals listed below.
387 .\"O Several signal numbers
388 .\"O are architecture-dependent, as indicated in the "Value" column.
389 .\"O (Where three values are given, the first one is usually valid for
390 .\"O alpha and sparc,
391 .\"O the middle one for ix86, ia64, ppc, s390, arm and sh,
392 .\"O and the last one for mips.
393 Linux は以下に示す標準シグナルに対応している。
394 シグナル番号の一部はアーキテクチャ依存であり、"値" 欄に示す通りである。
395 (3つの値が書かれているものは、 1つ目が alpha と sparc で通常有効な値、
396 真ん中が ix86, ia64, ppc, s390, arm, sh での値、最後が mips での値である。
397 .\" parisc is a law unto itself
398 .\"O A \- denotes that a signal is absent on the corresponding architecture.)
399 \- はそのアーキテクチャにおいて対応するシグナルがないことを示す。)
401 .\"O First the signals described in the original POSIX.1-1990 standard.
402 最初に、POSIX.1-1990 に定義されているシグナルを示す。
407 .\"O Signal Value Action Comment
409 .\"O SIGHUP \01 Term Hangup detected on controlling terminal
410 .\"O or death of controlling process
412 制御端末(controlling terminal)のハングアップ検出、
415 .\"O SIGINT \02 Term Interrupt from keyboard
416 .\"O SIGQUIT \03 Core Quit from keyboard
417 .\"O SIGILL \04 Core Illegal Instruction
418 .\"O SIGABRT \06 Core Abort signal from \fBabort\fP(3)
419 .\"O SIGFPE \08 Core Floating point exception
420 .\"O SIGKILL \09 Term Kill signal
421 SIGINT \02 Term キーボードからの割り込み (Interrupt)
422 SIGQUIT \03 Core キーボードによる中止 (Quit)
423 SIGILL \04 Core 不正な命令
424 SIGABRT \06 Core \fBabort\fP(3) からの中断 (Abort) シグナル
425 SIGFPE \08 Core 浮動小数点例外
426 SIGKILL \09 Term Kill シグナル
427 .\"O SIGSEGV 11 Core Invalid memory reference
428 .\"O SIGPIPE 13 Term Broken pipe: write to pipe with no
430 .\"O SIGALRM 14 Term Timer signal from \fBalarm\fP(2)
431 .\"O SIGTERM 15 Term Termination signal
432 SIGSEGV 11 Core 不正なメモリ参照
433 SIGPIPE 13 Term パイプ破壊: 読み手の無いパイプへの書き出し
434 SIGALRM 14 Term \fBalarm\fP(2) からのタイマーシグナル
435 SIGTERM 15 Term 終了 (termination) シグナル
436 .\"O SIGUSR1 30,10,16 Term User-defined signal 1
437 .\"O SIGUSR2 31,12,17 Term User-defined signal 2
438 .\"O SIGCHLD 20,17,18 Ign Child stopped or terminated
439 .\"O SIGCONT 19,18,25 Cont Continue if stopped
440 SIGUSR1 30,10,16 Term ユーザ定義シグナル 1
441 SIGUSR2 31,12,17 Term ユーザ定義シグナル 2
442 SIGCHLD 20,17,18 Ign 子プロセスの一時停止 (stop) または終了
443 SIGCONT 19,18,25 Cont 一時停止 (stop) からの再開
444 .\"O SIGSTOP 17,19,23 Stop Stop process
445 .\"O SIGTSTP 18,20,24 Stop Stop typed at tty
446 .\"O SIGTTIN 21,21,26 Stop tty input for background process
447 .\"O SIGTTOU 22,22,27 Stop tty output for background process
448 SIGSTOP 17,19,23 Stop プロセスの一時停止 (stop)
449 SIGTSTP 18,20,24 Stop 端末 (tty) より入力された一時停止 (stop)
450 SIGTTIN 21,21,26 Stop バックグランドプロセスの tty 入力
451 SIGTTOU 22,22,27 Stop バックグランドプロセスの tty 出力
458 .\"O cannot be caught, blocked, or ignored.
465 .\"O Next the signals not in the POSIX.1-1990 standard but described in
466 .\"O SUSv2 and POSIX.1-2001.
467 次に、 POSIX.1-1990 標準にはないが、 SUSv2 と
468 POSIX.1-2001 に記述されているシグナルを示す。
473 .\"O Signal Value Action Comment
475 .\"O SIGBUS 10,7,10 Core Bus error (bad memory access)
476 .\"O SIGPOLL Term Pollable event (Sys V).
477 .\"O Synonym for \fBSIGIO\fP
478 .\"O SIGPROF 27,27,29 Term Profiling timer expired
479 SIGBUS 10,7,10 Core バスエラー (不正なメモリアクセス)
480 SIGPOLL Term ポーリング可能なイベント (Sys V)。
482 SIGPROF 27,27,29 Term profiling タイマの時間切れ
483 .\"O SIGSYS 12,31,12 Core Bad argument to routine (SVr4)
484 .\"O SIGTRAP 5 Core Trace/breakpoint trap
485 .\"O SIGURG 16,23,21 Ign Urgent condition on socket (4.2BSD)
486 SIGSYS 12,31,12 Core ルーチンへの引き数が不正 (SVr4)
487 SIGTRAP 5 Core トレース/ブレークポイント トラップ
488 SIGURG 16,23,21 Ign T{
489 ソケットの緊急事態 (urgent condition) (4.2BSD)
491 .\"O SIGVTALRM 26,26,28 Term Virtual alarm clock (4.2BSD)
492 .\"O SIGXCPU 24,24,30 Core CPU time limit exceeded (4.2BSD)
493 .\"O SIGXFSZ 25,25,31 Core File size limit exceeded (4.2BSD)
494 SIGVTALRM 26,26,28 Term 仮想アラームクロック (4.2BSD)
495 SIGXCPU 24,24,30 Core CPU時間制限超過 (4.2BSD)
496 SIGXFSZ 25,25,31 Core ファイルサイズ制限の超過 (4.2BSD)
499 .\"O Up to and including Linux 2.2, the default behavior for
500 .\"O .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ ", "
501 .\"O and (on architectures other than SPARC and MIPS)
503 .\"O was to terminate the process (without a core dump).
504 .\"O (On some other UNIX systems the default action for
505 .\"O .BR SIGXCPU " and " SIGXFSZ
506 .\"O is to terminate the process without a core dump.)
507 .\"O Linux 2.4 conforms to the POSIX.1-2001 requirements for these signals,
508 .\"O terminating the process with a core dump.
510 .BR SIGSYS ", " SIGXCPU ", " SIGXFSZ
511 および SPARC と MIPS 以外のアーキテクチャでの
513 のデフォルトの振る舞いは (コアダンプ出力なしの) プロセス終了であった。
515 .BR SIGXCPU " と " SIGXFSZ
516 のデフォルトの動作がコアダンプなしのプロセス終了のものがある。)
517 Linux 2.4 では、POSIX.1-2001 での要求仕様に準拠して、
518 これらのシグナルで、プロセスを終了させ、コアダンプを出力する
521 .\"O Next various other signals.
527 .\"O Signal Value Action Comment
529 .\"O SIGIOT 6 Core IOT trap. A synonym for \fBSIGABRT\fP
530 .\"O SIGEMT 7,\-,7 Term
531 .\"O SIGSTKFLT \-,16,\- Term Stack fault on coprocessor (unused)
532 .\"O SIGIO 23,29,22 Term I/O now possible (4.2BSD)
533 .\"O SIGCLD \-,\-,18 Ign A synonym for \fBSIGCHLD\fP
534 SIGIOT 6 Core IOT トラップ。\fBSIGABRT\fP と同義
536 SIGSTKFLT \-,16,\- A T{
537 数値演算プロセッサにおけるスタックフォルト (未使用)
539 SIGIO 23,29,22 Term 入出力が可能になった (4.2BSD)
540 SIGCLD \-,\-,18 Ign \fBSIGCHLD\fP と同義
541 .\"O SIGPWR 29,30,19 Term Power failure (System V)
542 .\"O SIGINFO 29,\-,\- A synonym for \fBSIGPWR\fP
543 .\"O SIGLOST \-,\-,\- Term File lock lost
544 .\"O SIGWINCH 28,28,20 Ign Window resize signal (4.3BSD, Sun)
545 .\"O SIGUNUSED \-,31,\- Core Synonymous with \fBSIGSYS\fP
546 SIGPWR 29,30,19 Term 電源喪失 (Power failure) (System V)
547 SIGINFO 29,\-,\- \fBSIGPWR\fP と同義
548 SIGLOST \-,\-,\- Term ファイルロックが失われた
549 SIGWINCH 28,28,20 Ign T{
550 ウィンドウ リサイズ シグナル (4.3BSD, Sun)
552 SIGUNUSED \-,31,\- Core \fBSIGSYS\fP と同義
571 .\"O is not specified in POSIX.1-2001, but nevertheless appears
572 .\"O on most other UNIX systems,
573 .\"O where its default action is typically to terminate
574 .\"O the process with a core dump.
576 は POSIX.1-2001 に規定されていないが、
577 その他の多くの UNIX システムに存在する。
578 デフォルトの動作は多くの場合、コアダンプ出力を伴うプロセスの終了である。
581 .\"O (which is not specified in POSIX.1-2001) is typically ignored
582 .\"O by default on those other UNIX systems where it appears.
584 は (POSIX.1-2001 に規定されていないが) このシグナルが存在する
585 他の UNIX システムでは多くの場合、デフォルト動作は無視である。
588 .\"O (which is not specified in POSIX.1-2001) is ignored by default
589 .\"O on several other UNIX systems.
591 は (POSIX.1-2001 に規定されていないが) いくつかの他の UNIX システムでは
596 .\"O is synonymous with
597 .\"O .\" parisc is the only exception: SIGSYS is 12, SIGUNUSED is 31
599 .\"O on most architectures.
601 が定義されている場合には、ほとんどのアーキテクチャで
604 .\" parisc is the only exception: SIGSYS is 12, SIGUNUSED is 31
605 .\"O .SS "Real-time Signals"
607 .\"O Linux supports real-time signals as originally defined in the POSIX.1b
608 .\"O real-time extensions (and now included in POSIX.1-2001).
609 Linux はリアルタイムシグナルをサポートしている。
610 リアルタイムシグナルは元々 POSIX.1b のリアルタイム拡張で定義されて
611 いるものであり、現在では POSIX.1-2001 に含まれている。
612 .\"O The range of supported real-time signals is defined by the macros
616 .\"O POSIX.1-2001 requires that an implementation support at least
617 .\"O .B _POSIX_RTSIG_MAX
618 .\"O (8) real-time signals.
619 対応しているリアルタイムシグナルの範囲は、マクロ
624 POSIX.1-2001 では、少なくとも
626 (8) 個のリアルタイムシグナルに対応した実装が要求されている。
628 .\"O The Linux kernel supports a range of 32 different real-time
629 .\"O signals, numbered 33 to 64.
630 .\"O However, the glibc POSIX threads implementation internally uses
631 .\"O two (for NPTL) or three (for LinuxThreads) real-time signals
633 .\"O .BR pthreads (7)),
634 .\"O and adjusts the value of
636 .\"O suitably (to 34 or 35).
637 Linux は、32 個の異なるリアルタイムシグナルに対応しており、
639 しかしながら、glibc の POSIX スレッド実装は、
640 内部で 2個 (NPTL の場合) か 3個 (LinuxThreads の場合) の
645 の値を適切に (34 か 35 に) 調整する。
646 .\"O Because the range of available real-time signals varies according
647 .\"O to the glibc threading implementation (and this variation can occur
648 .\"O at run time according to the available kernel and glibc),
649 .\"O and indeed the range of real-time signals varies across UNIX systems,
651 .\"O .IR "never refer to real-time signals using hard-coded numbers" ,
652 .\"O but instead should always refer to real-time signals using the notation
653 .\"O .BR SIGRTMIN +n,
654 .\"O and include suitable (run-time) checks that
658 利用可能なリアルタイムシグナルの範囲は glibc のスレッド実装により
659 異なるし (使用するカーネルと glibc により実行時にも変化する)、
660 UNIX システムの種類によっても異なる。したがって、
661 プログラムでは「ハードコーディングした数字を使ってのリアルタイムシグナルの
668 を超えていないかのチェックを (実行時に) 適切に行うべきである。
670 .\"O Unlike standard signals, real-time signals have no predefined meanings:
671 .\"O the entire set of real-time signals can be used for application-defined
673 標準シグナルと異なり、リアルタイムシグナルには
675 リアルタイムシグナルの全部をアプリケーションで定義した用途に使える。
677 .\"O The default action for an unhandled real-time signal is to terminate the
678 .\"O receiving process.
679 ハンドリングしないリアルタイムシグナルのデフォルトの動作は
682 .\"O Real-time signals are distinguished by the following:
685 .\"O Multiple instances of real-time signals can be queued.
686 .\"O By contrast, if multiple instances of a standard signal are delivered
687 .\"O while that signal is currently blocked, then only one instance is queued.
688 リアルタイムシグナルは複数の実体をキューに入れることができる。
689 一方、標準シグナルの場合、そのシグナルがブロックされている間に
690 同じシグナルの複数のインスタンスが配送されても、
693 .\"O If the signal is sent using
694 .\"O .BR sigqueue (3),
695 .\"O an accompanying value (either an integer or a pointer) can be sent
696 .\"O with the signal.
700 付属データ (整数かポインタ) をシグナルと共に送信できる。
701 .\"O If the receiving process establishes a handler for this signal using the
704 .\"O .BR sigaction (2)
705 .\"O then it can obtain this data via the
709 .\"O structure passed as the second argument to the handler.
714 フラグを指定してシグナルハンドラを設定した場合、
719 フィールド経由でハンドラの第 2 引き数として渡され、
721 .\"O Furthermore, the
725 .\"O fields of this structure can be used to obtain the PID
726 .\"O and real user ID of the process sending the signal.
731 フィールドでシグナルを送信したプロセスの PID と実ユーザ ID を
734 .\"O Real-time signals are delivered in a guaranteed order.
735 .\"O Multiple real-time signals of the same type are delivered in the order
737 .\"O If different real-time signals are sent to a process, they are delivered
738 .\"O starting with the lowest-numbered signal.
739 .\"O (I.e., low-numbered signals have highest priority.)
740 .\"O By contrast, if multiple standard signals are pending for a process,
741 .\"O the order in which they are delivered is unspecified.
742 リアルタイムシグナルでは配送される順序が保証される。
743 同じタイプのリアルタイムシグナルは送信された順番に到着する。
744 異なるリアルタイムシグナルが一つのプロセスに送信された場合、
746 (つまり小さい番号のシグナルが高い優先順位を持つ。)
747 対照的に、一つのプロセスに対して複数の標準シグナルが処理待ちとなった場合、
748 これらのシグナルが配送される順序は不定である。
750 .\"O If both standard and real-time signals are pending for a process,
751 .\"O POSIX leaves it unspecified which is delivered first.
752 .\"O Linux, like many other implementations, gives priority
753 .\"O to standard signals in this case.
754 一つのプロセスに対して標準シグナルとリアルタイムシグナルの両方が
755 処理待ちの場合、POSIX はどちらが先に配送されるかを規定していない。
756 Linux では、他の多くの実装と同様、このような場合には
759 .\"O According to POSIX, an implementation should permit at least
760 .\"O .B _POSIX_SIGQUEUE_MAX
761 .\"O (32) real-time signals to be queued to
763 POSIX によれば、1 プロセス毎に最低
764 .B _POSIX_SIGQUEUE_MAX
765 (32) 個のリアルタイムシグナルをキューに入れられるべきとしている。
766 .\"O However, Linux does things differently.
767 .\"O In kernels up to and including 2.6.7, Linux imposes
768 .\"O a system-wide limit on the number of queued real-time signals
769 .\"O for all processes.
770 しかし、 Linux では違った実装になっている。カーネル 2.6.7 までは
771 (2.6.7 を含む)、全プロセスでキューに入っているリアルタイムシグナル
772 の数の合計についてシステム全体での制限がある。
773 .\"O This limit can be viewed and (with privilege) changed via the
774 .\"O .I /proc/sys/kernel/rtsig-max
777 .\"O .IR /proc/sys/kernel/rtsig-nr ,
778 .\"O can be used to find out how many real-time signals are currently queued.
780 .I /proc/sys/kernel/rtsig-max
781 ファイルで見ることができ、 (権限があれば) 変更もできる。
783 .I /proc/sys/kernel/rtsig-nr
784 を見ることで、いくつのリアルタイムシグナルが現在キューに入っているかを
786 .\"O In Linux 2.6.8, these
788 .\"O interfaces were replaced by the
789 .\"O .B RLIMIT_SIGPENDING
790 .\"O resource limit, which specifies a per-user limit for queued
792 .\"O .BR setrlimit (2)
793 .\"O for further details.
799 これは、キューに入るシグナル数に関してユーザ単位に
804 .\"O .SS "Async-signal-safe functions"
805 .SS "非同期シグナルで安全な関数 (async-signal-safe functions)"
807 .\"O A signal handler function must be very careful,
808 .\"O since processing elsewhere may be interrupted
809 .\"O at some arbitrary point in the execution of the program.
810 .\"O POSIX has the concept of "safe function".
811 .\"O If a signal interrupts the execution of an unsafe function, and
813 .\"O calls an unsafe function, then the behavior of the program is undefined.
814 シグナルハンドラ関数には非常に注意しなければならない。
815 他の場所の処理はプログラム実行の任意の箇所で中断される可能性があるためである。
816 POSIX には「安全な関数 (safe function)」という概念がある。
817 シグナルが安全でない関数の実行を中断し、かつ
819 が安全でない関数を呼び出した場合、プログラムの挙動は未定義である。
821 .\"O POSIX.1-2004 (also known as POSIX.1-2001 Technical Corrigendum 2)
822 .\"O requires an implementation to guarantee that the following
823 .\"O functions can be safely called inside a signal handler:
824 POSIX.1-2004 (POSIX.1-2001 Technical Corrigendum (正誤表) 2 とも言う) では、
825 シグナルハンドラ内での安全な呼び出しを保証することが必須の関数として
951 .\"O POSIX.1-2008 removes fpathconf(), pathconf(), and sysconf()
952 .\"O from the above list, and adds the following functions:
953 POSIX.1-2008 では、上記のリストのうち fpathconf(), pathconf(), sysconf()
980 .\"O .SS Interruption of System Calls and Library Functions by Signal Handlers
981 .SS シグナルハンドラによるシステムコールやライブラリ関数への割り込み
982 .\"O If a signal handler is invoked while a system call or library
983 .\"O function call is blocked, then either:
984 システムコールやライブラリが停止 (block) している間にシグナルハンドラが
987 .\"O the call is automatically restarted after the signal handler returns; or
988 シグナルが返った後、呼び出しは自動的に再スタートされる。
990 .\"O the call fails with the error
996 .\"O Which of these two behaviors occurs depends on the interface and
997 .\"O whether or not the signal handler was established using the
1000 .\"O .BR sigaction (2)).
1001 .\"O The details vary across UNIX systems;
1002 .\"O below, the details for Linux.
1003 これらの二つの挙動のうちどちらが起こるかは、インターフェイスにより依存し、
1008 参照) を使って設定されていたかにも依存する。
1009 詳細は UNIX システムによって異なる。
1010 Linux における詳細を以下で説明する。
1012 .\"O If a blocked call to one of the following interfaces is interrupted
1013 .\"O by a signal handler, then the call will be automatically restarted
1014 .\"O after the signal handler returns if the
1016 .\"O flag was used; otherwise the call will fail with the error
1018 .\"O .\" The following system calls use ERESTARTSYS,
1019 .\"O .\" so that they are restartable
1020 以下のインターフェイスのいずれかの呼び出しが停止している間に
1021 シグナルハンドラにより割り込まれた場合、
1023 フラグが使用されていれば、シグナルハンドラが返った後に
1024 その呼び出しは自動的に再スタートされることになる。
1028 .\" 以下のシステムコールは ERESTARTSYS を使っている。
1029 .\" そのため、これらは再スタートが可能である。
1035 .\"O .BR writev (2),
1038 .\"O calls on "slow" devices.
1039 .\"O A "slow" device is one where the I/O call may block for an
1040 .\"O indefinite time, for example, a terminal, pipe, or socket.
1041 .\"O (A disk is not a slow device according to this definition.)
1042 .\"O If an I/O call on a slow device has already transferred some
1043 .\"O data by the time it is interrupted by a signal handler,
1044 .\"O then the call will return a success status
1045 .\"O (normally, the number of bytes transferred).
1051 の「遅い (slow)」デバイスに対する呼び出し。
1052 ここでいう「遅い」デバイスとは、I/O 呼び出しが無期限に停止 (block) する
1053 可能性のあるデバイスのことで、例としては端末、パイプ、ソケットがある
1054 (この定義では、ディスクは遅いデバイスではない)。
1055 遅いデバイスに対する I/O 呼び出しが、
1056 シグナルハンドラにより割り込まれた時点までに何らかのデータを
1057 すでに転送していれば、呼び出しは成功ステータス
1058 (通常は、転送されたバイト数) を返すことだろう。
1061 .\"O if it can block (e.g., when opening a FIFO; see
1072 .\"O .BR waitid (2),
1074 .\"O .BR waitpid (2).
1081 .\"O Socket interfaces:
1083 .\" If a timeout (setsockopt()) is in effect on the socket, then these
1084 .\" system calls switch to using EINTR. Consequently, they and are not
1085 .\" automatically restarted, and they show the stop/cont behavior
1086 .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)
1087 .\"O .BR accept (2),
1088 .\"O .BR connect (2),
1090 .\"O .BR recvfrom (2),
1091 .\"O .BR recvmsg (2),
1093 .\"O .BR sendto (2),
1095 .\"O .BR sendmsg (2),
1096 .\"O unless a timeout has been set on the socket (see below).
1105 但し、ソケットにタイムアウトが設定されていない場合 (下記参照)。
1107 .\"O File locking interfaces:
1117 .\"O POSIX message queue interfaces:
1118 POSIX メッセージキューインターフェイス:
1120 .BR mq_timedreceive (3),
1123 .BR mq_timedsend (3).
1127 .\"O (since Linux 2.6.22; beforehand, always failed with
1129 (Linux 2.6.22 以降; それ以前は常に
1133 .\"O POSIX semaphore interfaces:
1135 .\"O .BR sem_wait (3)
1137 .\"O .BR sem_timedwait (3)
1138 .\"O (since Linux 2.6.22; beforehand, always failed with
1141 .BR sem_timedwait (3)
1142 (Linux 2.6.22 以降; それ以前は常に
1147 .\"O The following interfaces are never restarted after
1148 .\"O being interrupted by a signal handler,
1149 .\"O regardless of the use of
1150 .\"O .BR SA_RESTART ;
1151 .\"O they always fail with the error
1153 .\"O when interrupted by a signal handler:
1154 .\"O .\" These are the system calls that give EINTR or ERESTARTNOHAND
1155 .\"O .\" on interruption by a signal handler.
1158 を使っているどうかに関わらず、シグナルハンドラにより割り込まれた後、
1160 これらは、シグナルハンドラにより割り込まれると、常にエラー
1163 .\" これらは、シグナルハンドラによる割り込みの際に
1164 .\" EINTR か ERESTARTNOHAND を返すシステムコールである。
1167 .\"O Socket interfaces, when a timeout has been set on the socket using
1168 .\"O .BR setsockopt (2):
1169 .\"O .BR accept (2),
1171 .\"O .BR recvfrom (2),
1173 .\"O .BR recvmsg (2),
1174 .\"O if a receive timeout
1175 .\"O .RB ( SO_RCVTIMEO )
1177 .\"O .BR connect (2),
1179 .\"O .BR sendto (2),
1181 .\"O .BR sendmsg (2),
1182 .\"O if a send timeout
1183 .\"O .RB ( SO_SNDTIMEO )
1186 を使ってタイムアウトが設定されているソケットインターフェース:
1202 .\"O Interfaces used to wait for signals:
1203 シグナル待ちに使われるインターフェイス:
1206 .BR sigtimedwait (2),
1208 .BR sigwaitinfo (2).
1210 .\"O File descriptor multiplexing interfaces:
1211 ファイルディスクリプタ多重インターフェイス:
1213 .BR epoll_pwait (2),
1220 .\"O System V IPC interfaces:
1221 System V IPC インターフェイス:
1222 .\" On some other systems, SA_RESTART does restart these system calls
1229 .\"O Sleep interfaces:
1231 .BR clock_nanosleep (2),
1238 .\"O .BR inotify (7)
1239 .\"O file descriptor.
1244 .BR io_getevents (2).
1249 .\"O function is also never restarted if interrupted by a handler,
1250 .\"O but gives a success return: the number of seconds remaining to sleep.
1252 関数も、ハンドラにより割り込まれた場合、決して再スタートされることはない。
1253 しかし、成功となり、残っている停止時間を返す。
1254 .\"O .SS Interruption of System Calls and Library Functions by Stop Signals
1255 .SS 一時停止シグナルによるシステムコールやライブラリ関数への割り込み
1256 .\"O On Linux, even in the absence of signal handlers,
1257 .\"O certain blocking interfaces can fail with the error
1259 .\"O after the process is stopped by one of the stop signals
1260 .\"O and then resumed via
1262 .\"O This behavior is not sanctioned by POSIX.1, and doesn't occur
1263 .\"O on other systems.
1264 Linux では、シグナルハンドラが設定されていない場合でも、
1265 いくつかのブロッキング型のインターフェイスは、
1266 プロセスが一時停止 (stop) シグナルの一つにより停止され、
1271 この挙動は POSIX.1 で認められておらず、他のシステムでは起こらない。
1273 .\"O The Linux interfaces that display this behavior are:
1274 この挙動を示す Linux のインターフェイスは以下の通りである。
1277 .\"O Socket interfaces, when a timeout has been set on the socket using
1278 .\"O .BR setsockopt (2):
1279 .\"O .BR accept (2),
1281 .\"O .BR recvfrom (2),
1283 .\"O .BR recvmsg (2),
1284 .\"O if a receive timeout
1285 .\"O .RB ( SO_RCVTIMEO )
1287 .\"O .BR connect (2),
1289 .\"O .BR sendto (2),
1291 .\"O .BR sendmsg (2),
1292 .\"O if a send timeout
1293 .\"O .RB ( SO_SNDTIMEO )
1296 を使ってタイムアウトが設定されているソケットインターフェース:
1313 .BR epoll_pwait (2).
1318 .BR sigtimedwait (2),
1319 .BR sigwaitinfo (2).
1323 .\"O .BR inotify (7)
1324 .\"O file descriptor.
1329 .\"O Linux 2.6.21 and earlier:
1333 .BR sem_timedwait (3),
1336 .\"O Linux 2.6.8 and earlier:
1341 .\"O Linux 2.4 and earlier:
1345 .\"O .SH "CONFORMING TO"
1347 .\"O POSIX.1, except as noted.
1354 .\"O have the same value.
1355 .\"O The latter is commented out in the kernel source, but
1356 .\"O the build process of some software still thinks that
1364 はカーネルのソースではコメントアウトされている。
1365 しかし、ソフトウェアによってはビルドの過程でシグナル 29 を
1374 .BR rt_sigqueueinfo (2),
1379 .BR sigaltstack (2),
1383 .BR sigprocmask (2),
1385 .BR sigwaitinfo (2),
1390 .BR pthread_sigqueue (3),
1397 .BR sysv_signal (3),