sigactionのヘルプ・マニュアル
日本語 英語
sigaction --help
man sigaction
SIGACTION(2) Linux Programmer’s Manual SIGACTION(2)
名前
sigaction - シグナルの動作の確認と変更
書式
#include
int sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
説明
sigaction() システムコールは、特定のシグナルを受信した際のプロセスの動
作を変更するのに使用される (シグナルの概要については signal(7) を参 照)
。
signum には、 SIGKILL と SIGSTOP 以外の有効なシグナルをどれでも指定でき
る。
act が NULL 以外であれば、シグナル signum の新しい動作 (action) とし て
act が設定される。 oldact が NULL でなければ、今までの動作が oldact に
格納される。
sigaction 構造体は以下のような感じに定義される。
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
アーキテクチャによっては共用体 (union) が用いられており、その場合 に は
sa_handler と sa_sigaction の両方を同時に割り当てることはできない。
sa_restorer 要 素 は 廃 止 予 定であり使用すべきではない。 POSIX には
sa_restorer 要素に関する規定はない。
sa_handler は signum に対応する動作を指定するもので、デフォルトの動作を
行 う SIG_DFL、そのシグナルを無視する SIG_IGN、シグナルハンドラ関数への
ポインタが設定できる。シグナルハンドラ関数の引き数は一つであり、シグ ナ
ル番号が引き数として渡される。
sa_flags に SA_SIGINFO が 指 定 された場合、 (sa_handler ではなく)
sa_sigaction により signum に対応するシグナルハンドル関数が指定される。
指 定される関数は、最初の引き数としてシグナル番号を、二番目の引き数とし
て siginfo_t へのポインタを、三番目の引き数として (void * にキャスト し
た) ucontext_t へのポインタを受けとる。
sa_mask は、シグナル・ハンドラ実行中に禁止 (block) すべきシグナルのマス
クを指定する (ハンドラ実行中のシグナルの禁止は、シグナル・ハンドラが 起
動 さ れたスレッドのシグナルのマスクに追加することで行われる)。さらに、
SA_NODEFER フラグが指定されていない場合は、ハンドラを起動するきっかけと
なるシグナルにも sa_mask が適用される。
sa_flags はシグナル・ハンドラの動作を変更するためのフラグの集合を指定す
る。 sa_flags には、以下に示すフラグの (0 個以上の) 論理和をとったも の
を指定する。
SA_NOCLDSTOP
signum が SIGCHLD の場合、子プロセスが停止したり (子プロセス
が SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU を受けたとき) 再開した
り (子プロセスが SIGCONT を受けたとき) したときに SIGCHLD の
通知を受けない。このフラグは、 SIGCHLD に対してハンドラを 設
定する際にのみ意味を持つ。
SA_NOCLDWAIT (Linux 2.6 以降)
(Linux 2.6 以降) signum が SIGCHLD の場合、子プロセスが終了
したときに子プロセスをゾンビプロセスに変化させ な い (wait-
pid(2) も参照)。このフラグは、 SIGCHLD に対してハンドラを設
定する際、もしくはそのシグナルの処理方法を SIG_DFL に設定 す
る際にのみ意味を持つ。
SIGCHLD に対してハンドラを設定する際に SA_NOCLDWAIT フラグを
セットした場合、子プロセスが終了した際に SIGCHLD シグナル が
生 成されるかどうかは、 POSIX.1 では規定されていない。 Linux
では、この状況で SIGCHLD シグナルは生成される。いくつかの 他
の実装では生成されない。
SA_NODEFER
それ自身のシグナル・ハンドラーの内部にいる時でもそのシグナル
をマスクしないようにする。このフラグはシグナルハンドラを設定
す る際にのみ意味を持つ。 SA_NOMASK はこのフラグと同じ意味だ
が、廃止されており、非標準である。
SA_ONSTACK
sigaltstack(2) で提供される別のシグナル・スタックでシグナ ル
ハンドラを呼び出す。別のシグナル・スタックが利用可能でなけれ
ば、デフォルトのスタックが使用される。このフラグはシグナルハ
ンドラを設定する際にのみ意味を持つ。
SA_RESETHAND
シグナルハンドラが呼ばれる度に、シグナルの動作をデフォルトに
戻す。このフラグはシグナルハンドラを設定する際にのみ意味を持
つ。 SA_ONESHOT はこのフラグと同じ意味だが、廃止されており、
非標準である。
SA_RESTART
いくつかのシステムコールをシグナルの通知の前後で再開できるよ
うにして、 BSD シグナル方式 (semantics) と互換性のある動作を
提供する。このフラグはシグナルハンドラを設定する際にのみ意味
を 持つ。 signal(7) に書かれているシステムコールの再開に関す
る議論を参照のこと。
SA_SIGINFO (Linux 2.2 以降)
シグナルハンドラは一つではなく、三つの引き数を持つ。この場合
は sa_handler のかわりに sa_sigaction を設定しなければならな
いこのフラグはシグナルハンドラを設定する際にのみ意味を持つ。
sa_sigaction のパラメータ siginfo_t は以下の要素を持つ構造体である:
siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
sigval_t si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void *si_ptr; /* POSIX.1b signal */
int si_overrun; /* Timer overrun count; POSIX.1b timers */
int si_timerid; /* Timer ID; POSIX.1b timers */
void *si_addr; /* Memory location which caused fault */
int si_band; /* Band event */
int si_fd; /* File descriptor */
}
si_signo, si_errno, si_code は 全てのシグナルに対して定義されている
(si_errno は Linux では一般的には使用されない)。構造体の残りの部分は 、
共用体 (union) になっているかもしれない。その場合は該当するシグナルにお
いて意味のあるフィールドのみを読み込むことができる。
* POSIX.1b シグナルと SIGCHLD は si_pid と si_uid を設定する。
* POSIX.1b タイマ (Linux 2.6 以降) は si_overrun と si_timerid を設定す
る 。 si_timerid フィールドはカーネルがタイマを特定するのに使用する内
部 ID であり、 timer_create(2) が返すタイマ ID と同じではない。
* SIGCHLD は si_status, si_utime, si_stime を設定する。
* si_int と si_ptr は POSIX.1b シグナルの送信者によって指定される。詳細
は sigqueue(2) を参照のこと。
* SIGILL, SIGFPE, SIGSEGV, SIGBUS は si_addr にエラーが発生したアドレス
を設定する。 SIGPOLL は si_band と si_fd を設定する。
si_code は、そのシグナルが送信された理由を示す値である (ビットマスク で
は ない)。以下のリストに、どのシグナルの場合でも si_code に入りうる値を
、シグナルが生成された理由とともに記載する。
SI_USER kill(2) または raise(3)
SI_KERNEL カーネルにより送信された
SI_QUEUE sigqueue(2)
SI_TIMER POSIX タイマが満了した
SI_MESGQ POSIX メッセージキューの状態が変化した (Linux 2.6.6
以降)。 mq_notify(3)参照。
SI_ASYNCIO 非同期 IO (AIO) が完了した
SI_SIGIO キューイングされた SIGIO
SI_TKILL tkill(2) または tgkill(2) (Linux 2.4.19 以降)
SIGILL シグナルの場合、 si_code には以下の値を指定できる:
ILL_ILLOPC 不正な命令コード (opcode)
ILL_ILLOPN 不正なオペランド
ILL_ILLADR 不正なアドレッシングモード
ILL_ILLTRP 不正なトラップ
ILL_PRVOPC 特権が必要な命令コード (opcode)
ILL_PRVREG 特権が必要なレジスタ
ILL_COPROC コプロセッサのエラー
ILL_BADSTK 内部スタックエラー
SIGFPE シグナルの場合、 si_code には以下の値を指定できる:
FPE_INTDIV 整数の 0 による除算
FPE_INTOVF 整数のオーバーフロー
FPE_FLTDIV 浮動小数点の 0 による除算
FPE_FLTOVF 浮動小数点のオーバーフロー
FPE_FLTUND 浮動小数点のアンダーフロー
FPE_FLTRES 浮動小数点の不正確な演算結果 (inexact result)
FPE_FLTINV 浮動小数点の不正な操作
FPE_FLTSUB 範囲外の添字 (subscript)
SIGSEGV シグナルの場合、 si_code には以下の値を指定できる:
SEGV_MAPERR オブジェクトにマッピングされていないアドレス
SEGV_ACCERR マッピングされたオブジェクトに対するアクセス許可がな
い
SIGBUS シグナルの場合、 si_code には以下の値を指定できる:
BUS_ADRALN 不正なアドレス・アライメント (alignment)
BUS_ADRERR 存在しない物理アドレス
BUS_OBJERR オブジェクト固有のハードウェアエラー
SIGTRAP シグナルの場合、 si_code には以下の値を指定できる:
TRAP_BRKPT プロセスのブレークポイント
TRAP_TRACE プロセスのトレース・トラップ
SIGCHLD シグナルの場合、 si_code には以下の値を指定できる:
CLD_EXITED 子プロセスが終了した (exited)
CLD_KILLED 子プロセスが kill された
CLD_DUMPED 子プロセスが異常終了した
CLD_TRAPPED トレース対象の子プロセスがトラップを上げた
CLD_STOPPED 子プロセスが停止 (stop) した
CLD_CONTINUED 停止していた子プロセスが再開した (Linux 2.6.9 以降)
SIGPOLL シグナルの場合、 si_code には以下の値を指定できる:
POLL_IN 入力データが利用可能
POLL_OUT 出力バッファが利用可能
POLL_MSG 入力メッセージが利用可能
POLL_ERR I/O エラー
POLL_PRI 高優先の入力が利用可能
POLL_HUP デバイスが接続されていない
返り値
sigaction() は成功すれば 0 を返し、エラーならば -1 を返す。
エラー
EFAULT act か oldact が指しているメモリが正しいプロセスのアドレス空間に
ない。
EINVAL 無効なシグナルが指定された。補足 (catch) したり無視したりできな
いシグナルである SIGKILL や SIGSTOP に対する動作を変更しようとし
た場合にも発生する。
準拠
POSIX.1-2001, SVr4.
注意
fork(2) 経由で作成された子プロセスは、親プロセスのシグナルの処理方法の
コピーを継承する。 execve(2) の前後で、ハンドラが設定されているシグナル
の 処理方法はデフォルトにリセットされ、無視が設定されているシグナルの処
理方法は変更されずそのままとなる。
POSIX では、 kill(2) や raise(3) 関数で生成できないシ グ ナ ル SIGFPE,
SIGILL, SIGSEGV を無視 (ignore) した場合、その後の動作は未定義である。
ゼロによる整数割り算の結果は未定義となる。アーキテクチャーによっては 、
こ のとき SIGFPE シグナルが生成される。 (同様に負の最大整数を -1 で割る
と SIGFPE が生成されるかもしれない) このシグナルを無視すると無限ルー プ
に陥るかもしれない。
POSIX.1-1990 で は SIGCHLD に SIG_IGN を設定することを認めていない。
POSIX.1-2001 では認められており、 SIGCHLD を無視することでゾンビプロ セ
スの生成を防止することができる (wait(2) を参照)。さらに、BSD と SystemV
では SIGCHLD を無視した際の動作が異なっている。そのため、完全に移植性が
あ る 方 法で、終了した子プロセスがゾンビにならないことを保証するには、
SIGCHLD シグナルを補足し、 wait(2) などを実行するしかない。
POSIX.1-1990 の仕様では SA_NOCLDSTOP の み が 定 義 さ れ て い る 。
POSIX.1-2001 では SA_NOCLDWAIT, SA_RESETHAND, SA_NODEFER, SA_SIGINFO が
追加された。 Unix の古い実装で動かすアプリケーションで、他 の sa_flags
フラグを使用すると移植性が下がる。
SA_RESETHAND フラグは SVr4 の同じ名前のフラグと互換性がある。
SA_NODEFER フラグは 1.3.9 以降のカーネルでは同じ名前の SVr4 のフラグと
互換性がある。ぞれ以前の Linux カーネルの実装では、このフラグを設定して
い るシグナルだけでなく、どのシグナルでも受けることを許していた (実際に
は sa_mask の設定により無効にできる)。
sigaction() の二番目の引き数に NULL を指定して呼び出すと、現在のシグ ナ
ル ハ ンドラを確認することができる。また、二番目と三番目の引き数を NULL
にて呼び出すことで、指定されたシグナルが現在のマシンで使えるかどうか チ
ェックできる。
SIGKILL や SIGSTOP を (sa_mask に指定して) 禁止することはできない。禁止
しようとしても黙って無視される。
シグナル集合の操作に関する詳細は sigsetops(3) を参照すること。
シグナルハンドラ内から安全に呼び出すことができ る 、 async-signal-safe
functions (非同期シングルで安全な関数) のリストについては signal(7) を
参照。
非公式
SA_SIGINFO が導入される前は、 struct sigcontext 型の二番目の引き数と 一
緒 に sa_handler を使用することで、いくつかの追加の情報を入手することが
できた。詳細についてはカーネルソースの関連部分を見てほしい。現在はこ の
使用法は廃止されている。
バグ
2.6.13 以前のカーネルでは、 sa_flags に SA_NODEFER を指定した場合、ハン
ドラが実行中に配送されたシグナル自身がマスクされなくなるだけで な く 、
sa_mask に指定されたシグナルもマスクされなくなる。このバグは、カーネル
2.6.14 で修正された。
例
mprotect(2) 参照。
関連項目
kill(1), kill(2), killpg(2), pause(2), sigaltstack(2), signal(2), sig-
nalfd(2), sigpending(2), sigprocmask(2), sigqueue(2), sigsuspend(2),
wait(2), raise(3), siginterrupt(3), sigsetops(3), sigvec(3), core(5),
signal(7)
Linux 2008-10-17 SIGACTION(2)
SIGACTION(2) Linux Programmer’s Manual SIGACTION(2)
NAME
sigaction - examine and change a signal action
SYNOPSIS
#include
int sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
DESCRIPTION
The sigaction() system call is used to change the action taken by a
process on receipt of a specific signal. (See signal(7) for an
overview of signals.)
signum specifies the signal and can be any valid signal except SIGKILL
and SIGSTOP.
If act is non-null, the new action for signal signum is installed from
act. If oldact is non-null, the previous action is saved in oldact.
The sigaction structure is defined as something like:
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
On some architectures a union is involved: do not assign to both
sa_handler and sa_sigaction.
The sa_restorer element is obsolete and should not be used. POSIX does
not specify a sa_restorer element.
sa_handler specifies the action to be associated with signum and may be
SIG_DFL for the default action, SIG_IGN to ignore this signal, or a
pointer to a signal handling function. This function receives the sig-
nal number as its only argument.
If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead of
sa_handler) specifies the signal-handling function for signum. This
function receives the signal number as its first argument, a pointer to
a siginfo_t as its second argument and a pointer to a ucontext_t (cast
to void *) as its third argument.
sa_mask specifies a mask of signals which should be blocked (i.e.,
added to the signal mask of the thread in which the signal handler is
invoked) during execution of the signal handler. In addition, the sig-
nal which triggered the handler will be blocked, unless the SA_NODEFER
flag is used.
sa_flags specifies a set of flags which modify the behavior of the sig-
nal. It is formed by the bitwise OR of zero or more of the following:
SA_NOCLDSTOP
If signum is SIGCHLD, do not receive notification when child
processes stop (i.e., when they receive one of SIGSTOP,
SIGTSTP, SIGTTIN or SIGTTOU) or resume (i.e., they receive
SIGCONT) (see wait(2)). This flag is only meaningful when
establishing a handler for SIGCHLD.
SA_NOCLDWAIT (Since Linux 2.6)
If signum is SIGCHLD, do not transform children into zombies
when they terminate. See also waitpid(2). This flag is
only meaningful when establishing a handler for SIGCHLD, or
when setting that signal’s disposition to SIG_DFL.
If the SA_NOCLDWAIT flag is set when establishing a handler
for SIGCHLD, POSIX.1 leaves it unspecified whether a SIGCHLD
signal is generated when a child process terminates. On
Linux, a SIGCHLD signal is generated in this case; on some
other implementations, it is not.
SA_NODEFER
Do not prevent the signal from being received from within
its own signal handler. This flag is only meaningful when
establishing a signal handler. SA_NOMASK is an obsolete,
non-standard synonym for this flag.
SA_ONSTACK
Call the signal handler on an alternate signal stack pro-
vided by sigaltstack(2). If an alternate stack is not
available, the default stack will be used. This flag is
only meaningful when establishing a signal handler.
SA_RESETHAND
Restore the signal action to the default state once the sig-
nal handler has been called. This flag is only meaningful
when establishing a signal handler. SA_ONESHOT is an obso-
lete, non-standard synonym for this flag.
SA_RESTART
Provide behavior compatible with BSD signal semantics by
making certain system calls restartable across signals.
This flag is only meaningful when establishing a signal han-
dler. See signal(7) for a discussion of system call
restarting.
SA_SIGINFO (since Linux 2.2)
The signal handler takes 3 arguments, not one. In this
case, sa_sigaction should be set instead of sa_handler.
This flag is only meaningful when establishing a signal han-
dler.
The siginfo_t argument to sa_sigaction is a struct with the following
elements:
siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
sigval_t si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void *si_ptr; /* POSIX.1b signal */
int si_overrun; /* Timer overrun count; POSIX.1b timers */
int si_timerid; /* Timer ID; POSIX.1b timers */
void *si_addr; /* Memory location which caused fault */
int si_band; /* Band event */
int si_fd; /* File descriptor */
}
si_signo, si_errno and si_code are defined for all signals. (si_errno
is generally unused on Linux.) The rest of the struct may be a union,
so that one should only read the fields that are meaningful for the
given signal:
* POSIX.1b signals and SIGCHLD fill in si_pid and si_uid.
* POSIX.1b timers (since Linux 2.6) fill in si_overrun and si_timerid.
The si_timerid field is an internal ID used by the kernel to identify
the timer; it is not the same as the timer ID returned by timer_cre-
ate(2).
* SIGCHLD fills in si_status, si_utime and si_stime. The si_utime and
si_stime fields do not include the times used by waited for children
(unlike getrusage(2) and time(2). In kernels up to 2.6, and since
2.6.27, these fields report CPU time in units of
sysconf(_SC_CLK_TCK). In 2.6 kernels before 2.6.27, a bug meant that
these fields reported time in units of the (configurable) system
jiffy (see time(7)).
* si_int and si_ptr are specified by the sender of the POSIX.1b signal.
See sigqueue(2) for more details.
* SIGILL, SIGFPE, SIGSEGV, and SIGBUS fill in si_addr with the address
of the fault. SIGPOLL fills in si_band and si_fd.
si_code is a value (not a bit mask) indicating why this signal was
sent. The following list shows the values which can be placed in
si_code for any signal, along with reason that the signal was gener-
ated.
SI_USER kill(2) or raise(3)
SI_KERNEL Sent by the kernel.
SI_QUEUE sigqueue(2)
SI_TIMER POSIX timer expired
SI_MESGQ POSIX message queue state changed (since Linux
2.6.6); see mq_notify(3)
SI_ASYNCIO AIO completed
SI_SIGIO queued SIGIO
SI_TKILL tkill(2) or tgkill(2) (since Linux 2.4.19)
The following values can be placed in si_code for a SIGILL signal:
ILL_ILLOPC illegal opcode
ILL_ILLOPN illegal operand
ILL_ILLADR illegal addressing mode
ILL_ILLTRP illegal trap
ILL_PRVOPC privileged opcode
ILL_PRVREG privileged register
ILL_COPROC coprocessor error
ILL_BADSTK internal stack error
The following values can be placed in si_code for a SIGFPE signal:
FPE_INTDIV integer divide by zero
FPE_INTOVF integer overflow
FPE_FLTDIV floating-point divide by zero
FPE_FLTOVF floating-point overflow
FPE_FLTUND floating-point underflow
FPE_FLTRES floating-point inexact result
FPE_FLTINV floating-point invalid operation
FPE_FLTSUB subscript out of range
The following values can be placed in si_code for a SIGSEGV signal:
SEGV_MAPERR address not mapped to object
SEGV_ACCERR invalid permissions for mapped object
The following values can be placed in si_code for a SIGBUS signal:
BUS_ADRALN invalid address alignment
BUS_ADRERR nonexistent physical address
BUS_OBJERR object-specific hardware error
The following values can be placed in si_code for a SIGTRAP signal:
TRAP_BRKPT process breakpoint
TRAP_TRACE process trace trap
The following values can be placed in si_code for a SIGCHLD signal:
CLD_EXITED child has exited
CLD_KILLED child was killed
CLD_DUMPED child terminated abnormally
CLD_TRAPPED traced child has trapped
CLD_STOPPED child has stopped
CLD_CONTINUED stopped child has continued (since Linux 2.6.9)
The following values can be placed in si_code for a SIGPOLL signal:
POLL_IN data input available
POLL_OUT output buffers available
POLL_MSG input message available
POLL_ERR i/o error
POLL_PRI high priority input available
POLL_HUP device disconnected
RETURN VALUE
sigaction() returns 0 on success and -1 on error.
ERRORS
EFAULT act or oldact points to memory which is not a valid part of the
process address space.
EINVAL An invalid signal was specified. This will also be generated if
an attempt is made to change the action for SIGKILL or SIGSTOP,
which cannot be caught or ignored.
CONFORMING TO
POSIX.1-2001, SVr4.
NOTES
A child created via fork(2) inherits a copy of its parent’s signal dis-
positions. During an execve(2), the dispositions of handled signals
are reset to the default; the dispositions of ignored signals are left
unchanged.
According to POSIX, the behavior of a process is undefined after it
ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by
kill(2) or raise(3). Integer division by zero has undefined result.
On some architectures it will generate a SIGFPE signal. (Also dividing
the most negative integer by -1 may generate SIGFPE.) Ignoring this
signal might lead to an endless loop.
POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN.
POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be
used to prevent the creation of zombies (see wait(2)). Nevertheless,
the historical BSD and System V behaviors for ignoring SIGCHLD differ,
so that the only completely portable method of ensuring that terminated
children do not become zombies is to catch the SIGCHLD signal and per-
form a wait(2) or similar.
POSIX.1-1990 only specified SA_NOCLDSTOP. POSIX.1-2001 added SA_NOCLD-
WAIT, SA_RESETHAND, SA_NODEFER, and SA_SIGINFO. Use of these latter
values in sa_flags may be less portable in applications intended for
older Unix implementations.
The SA_RESETHAND flag is compatible with the SVr4 flag of the same
name.
The SA_NODEFER flag is compatible with the SVr4 flag of the same name
under kernels 1.3.9 and newer. On older kernels the Linux implementa-
tion allowed the receipt of any signal, not just the one we are
installing (effectively overriding any sa_mask settings).
sigaction() can be called with a null second argument to query the cur-
rent signal handler. It can also be used to check whether a given sig-
nal is valid for the current machine by calling it with null second and
third arguments.
It is not possible to block SIGKILL or SIGSTOP (by specifying them in
sa_mask). Attempts to do so are silently ignored.
See sigsetops(3) for details on manipulating signal sets.
See signal(7) for a list of the async-signal-safe functions that can be
safely called inside from inside a signal handler.
Undocumented
Before the introduction of SA_SIGINFO it was also possible to get some
additional information, namely by using a sa_handler with second argu-
ment of type struct sigcontext. See the relevant kernel sources for
details. This use is obsolete now.
BUGS
In kernels up to and including 2.6.13, specifying SA_NODEFER in
sa_flags prevents not only the delivered signal from being masked dur-
ing execution of the handler, but also the signals specified in
sa_mask. This bug was fixed in kernel 2.6.14.
EXAMPLE
See mprotect(2).
SEE ALSO
kill(1), kill(2), killpg(2), pause(2), sigaltstack(2), signal(2), sig-
nalfd(2), sigpending(2), sigprocmask(2), sigqueue(2), sigsuspend(2),
wait(2), raise(3), siginterrupt(3), sigsetops(3), sigvec(3), core(5),
signal(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2009-07-25 SIGACTION(2)