sigvecのヘルプ・マニュアル
日本語 英語
sigvec --help
man sigvec
SIGVEC(3) Linux Programmer’s Manual SIGVEC(3)
名前
sigvec, sigblock, sigsetmask, siggetmask, sigmask - BSD 版シグナル API
書式
#include
int sigvec(int sig, struct sigvec *vec, struct sigvec *ovec);
int sigmask(int signum);
int sigblock(int mask);
int sigsetmask(int mask);
int siggetmask(void);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
上記の全ての関数: _BSD_SOURCE
説明
こ れらの関数は、昔ながらの BSD 版シグナル API を使用しているプログラム
に対して互換性のあるインタフェースを glibc で提供するものである。 こ の
API は過去のものであり、新しいアプリケーションでは POSIX シグナル API
(sigaction(2), sigprocmask(2) など) を使用すべきである。
関数 sigvec() は、(POSIX の sigaction(2) と同様に) シグナル sig の動 作
の設定・取得を行う。 vec は、NULL 以外の場合、 sig の新しい動作を定義し
た sigvec 構造体へのポインタである。 ovec は、NULL 以外の場合、 sig の
変 更 前 の動作を返すために使用される sigvec 構造体へのポインタである。
sig の動作を変更せずに現在の動作を取得するためには、 vec に NULL を指定
し、 ovec に NULL でないポインタを指定すればよい。
SIGKILL と SIGSTOP の動作は変更できない。
sigvec 構造体は以下の通りである:
struct sigvec {
void (*sv_handler)(); /* Signal disposition */
int sv_mask; /* Signals to be blocked in handler */
int sv_flags; /* Flags */
};
sv_handler フィールドはシグナルの動作を指定するもので、シグナルハンドラ
関数のアドレスか、 SIG_DFL と SIG_IGN のいずれかを指定できる。 SIG_DFL
はシグナルに適用されるデフォルトの動作を意味し、 SIG_IGN はシグナルを無
視することを意味する。
sv_handler にシグナルハンドラのアドレスを指定した場合、 sv_mask はハ ン
ド ラが実行中にブロックされるべきシグナルのマスクを指定する。また、ハン
ドラを起動したシグナル自身はデフォルトでブロックされる 。 SIGKILL か
SIGSTOP をブロックしようとした場合には、黙って無視される。
sv_handler にシグナルハンドラのアドレスを指定した場合、 sv_flags フィー
ルドはハンドラが呼ばれた際の挙動を制御するフラグを指定する。このフィ ー
ルドには、0 か、以下のフラグを 1個以上指定できる:
SV_INTERRUPT
シグナルハンドラが停止中のシステムコールを中断した場合、ハンドラ
から復帰しても、システムコールは再開されず、エラー EINTR で失 敗
する。このフラグを指定しなかった場合、システムコールはデフォルト
で再開される。
SV_RESETHAND
シグナルハンドラを呼び出す前にシグナルの動作をデフォルトにリセッ
トする。このフラグを指定しなかった場合、もう一度 sigvec() を呼び
出して明示的に削除されるか、プロセスが execve(2) を実行するま で
、ハンドラは設定されたままとなる。
SV_ONSTACK
代 替 シ グ ナルスタック上でシグナルハンドラを実行する (歴史的に
、BSD では代替シグナルスタックは廃止された関数 sigstack() を使っ
て設定する。POSIX では、代わりに sigaltstack(2) を使用する)。
関数 sigmask() は signum に対する「シグナルマスク」を構成して返す。例え
ば、以下のようなコードを使うと、 sigvec() に渡す vec.sv_mask を初期化で
きる。
vec.sv_mask = sigmask(SIGQUIT) | sigpause(SIGABRT);
/* Block SIGQUIT and SIGABRT during
handler execution */
sigblock() 関数は、 mask にあるシグナルをプロセスのシグナルマスクに追加
し (POSIX の sigprocmask(SIG_BLOCK) と同様)、変更前のプロセスのシグナル
マ スクを返す。 SIGKILL や SIGSTOP をブロックしようとした場合には、黙っ
て無視される。
sigsetmask() 関数はプロセスのシグナルマスクを mask で指定された値に設定
し (POSIX の sigprocmask(SIG_SETMASK) と同様)、変更前のプロセスのシグナ
ルマスクを返す。
siggetmask() 関数はプロセスの現在のシグナルマスクを返す。こ の 関 数 は
sigblock(0) と等価である。
返り値
sigvec() 関数は成功すると 0 を返す。エラーの場合、-1 を返し、 errno に
エラーを示す値をセットする。
sigblock() と sigsetmask() は変更前のシグナルマスクを返す。
sigmask() 関数は signum のシグナルマスクを返す。
エラー
sigaction(2) と sigprocmask(2) の「エラー」の節を参照。
準拠
これらの関数のうち siggetmask() 以外の全ては 4.3BSD にあった。 sigget-
mask() の出自ははっきりしない。これらの関数は廃止予定であり、新しいプロ
グラムでは使用しないこと。
注意
4.3BSD では、信頼性のあるシグナル処理機構を提供する (vec.sv_mask を 0
で sigvec() を呼び出したときと同様)。 System V が提供する処理機構は信頼
性のないものである。 POSIX.1-2001 では、 signal() のこの点は規定しな い
ままとなっている。さらなる詳細については signal(2) を参照。
BSD と System V のどちらのシステムでもシグナルを待つために、 sig-
pause(3) という名前の関数が提供されているが、この関数の引き数は両方のシ
ステムで異なる。詳細は sigpause(3) を参照。
関連項目
kill(2), pause(2), sigaction(2), signal(2), sigprocmask(2), raise(3),
sigpause(3), sigset(3), signal(7)
Linux 2007-07-26 SIGVEC(3)
SIGVEC(3) Linux Programmer’s Manual SIGVEC(3)
NAME
sigvec, sigblock, sigsetmask, siggetmask, sigmask - BSD signal API
SYNOPSIS
#include
int sigvec(int sig, struct sigvec *vec, struct sigvec *ovec);
int sigmask(int signum);
int sigblock(int mask);
int sigsetmask(int mask);
int siggetmask(void);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
All functions shown above: _BSD_SOURCE
DESCRIPTION
These functions are provided in glibc as a compatibility interface for
programs that make use of the historical BSD signal API. This API is
obsolete: new applications should use the POSIX signal API (sigac-
tion(2), sigprocmask(2), etc.)
The sigvec() function sets and/or gets the disposition of the signal
sig (like the POSIX sigaction(2)). If vec is not NULL, it points to a
sigvec structure that defines the new disposition for sig. If ovec is
not NULL, it points to a sigvec structure that is used to return the
previous disposition of sig. To obtain the current disposition of sig
without changing it, specify NULL for vec, and a non-NULL pointer for
ovec.
The dispositions for SIGKILL and SIGSTOP cannot be changed.
The sigvec structure has the following form:
struct sigvec {
void (*sv_handler)(); /* Signal disposition */
int sv_mask; /* Signals to be blocked in handler */
int sv_flags; /* Flags */
};
The sv_handler field specifies the disposition of the signal, and is
either: the address of a signal handler function; or SIG_DFL meaning
the default disposition applies for the signal; or SIG_IGN meaning that
the signal is ignored.
If sv_handler specifies the address of a signal handler, then sv_mask
specifies a mask of signals that are to be blocked while the handler is
executing. In addition, the signal for which the handler is invoked is
also blocked by default. Attempts to block SIGKILL or SIGSTOP are
silently ignored.
If sv_handler specifies the address of a signal handler, then the
sv_flags field specifies flags controlling what happens when the han-
dler is called. This field may contain zero or more of the following
flags:
SV_INTERRUPT
If the signal handler interrupts a blocking system call, then
upon return from the handler the system call will not be
restarted: instead it will fail with the error EINTR. If this
flag is not specified, then system calls are restarted by
default.
SV_RESETHAND
Reset the disposition of the signal to the default before call-
ing the signal handler. If this flag is not specified, then the
handler remains established until explicitly removed by a later
call to sigvec() or until the process performs an execve(2).
SV_ONSTACK
Handle the signal on the alternate signal stack (historically
established under BSD using the obsolete sigstack() function;
the POSIX replacement is sigaltstack(2)).
The sigmask() function constructs and returns a "signal mask" for
signum. For example, we can initialize the vec.sv_mask field given to
sigvec() using code such as the following:
vec.sv_mask = sigmask(SIGQUIT) | sigpause(SIGABRT);
/* Block SIGQUIT and SIGABRT during
handler execution */
The sigblock() function adds the signals in mask to the process’s sig-
nal mask (like POSIX sigprocmask(SIG_BLOCK)), and returns the process’s
previous signal mask. Attempts to block SIGKILL or SIGSTOP are
silently ignored.
The sigsetmask() function sets the process’s signal mask to the value
given in mask (like POSIX sigprocmask(SIG_SETMASK)), and returns the
process’s previous signal mask.
The siggetmask() function returns the process’s current signal mask.
This call is equivalent to sigblock(0).
RETURN VALUE
The sigvec() function returns 0 on success; on error, it returns -1 and
sets errno to indicate the error.
The sigblock() and sigsetmask() functions return the previous signal
mask.
The sigmask() function returns the signal mask for signum.
ERRORS
See the ERRORS under sigaction(2) and sigprocmask(2).
CONFORMING TO
All of these functions were in 4.3BSD, except siggetmask(), whose ori-
gin is unclear. These functions are obsolete: do not use them in new
programs.
NOTES
On 4.3BSD, the signal() function provided reliable semantics (as when
calling sigvec() with vec.sv_mask equal to 0). On System V, signal()
provides unreliable semantics. POSIX.1-2001 leaves these aspects of
signal() unspecified. See signal(2) for further details.
In order to wait for a signal, BSD and System V both provided a func-
tion named sigpause(3), but this function has a different argument on
the two systems. See sigpause(3) for details.
SEE ALSO
kill(2), pause(2), sigaction(2), signal(2), sigprocmask(2), raise(3),
sigpause(3), sigset(3), 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 2007-07-26 SIGVEC(3)