.\" Copyright (c) 2002 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" added note on self-signaling, aeb, 2002-06-07 .\" added note on CAP_KILL, mtk, 2004-06-16 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2002, 2005 Yuichi SATO .\" all rights reserved. .\" Translated 2002-08-06, Yuichi SATO .\" Updated & Modified 2005-01-08, Yuichi SATO .\" Updated 2007-09-08, Akihiro MOTOKI , LDP v2.64 .\" Updated 2013-05-04, Akihiro MOTOKI .\" .TH SIGQUEUE 3 2013\-12\-16 Linux "Linux Programmer's Manual" .SH 名前 sigqueue \- シグナルとデータをプロセスに送る .SH 書式 \fB#include \fP .sp \fBint sigqueue(pid_t \fP\fIpid\fP\fB, int \fP\fIsig\fP\fB, const union sigval \fP\fIvalue\fP\fB);\fP .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBsigqueue\fP(): _POSIX_C_SOURCE\ >=\ 199309L .SH 説明 \fBsigqueue\fP() は \fIsig\fP で指定されたシグナルを、PID が \fIpid\fP であるプロセスに送る。 シグナルを送るのに必要な権限は \fBkill\fP(2) と同じである。 \fBkill\fP(2) と同様に、ヌルシグナル (0) を使って 指定した PID のプロセスが存在するかをチェックすることができる。 .PP \fIvalue\fP 引き数はシグナルと一緒に送るデータの付属アイテムを指定する。 \fIvalue\fP は (整数またはポインターの値であり) 以下のような型である。 .sp .in +4n .nf union sigval { int sival_int; void *sival_ptr; }; .fi .in 受取先のプロセスに、このシグナルに対するハンドラーを (\fBsigaction\fP(2) に \fBSA_SIGINFO\fP を指定して) インストールしておくと、 そのハンドラーの第 2 引き数に渡される \fIsiginfo_t\fP 構造体の \fIsi_value\fP フィールドによって、このデータを取得できる。 さらに、この構造体の \fIsi_code\fP フィールドは \fBSI_QUEUE\fP に設定される。 .SH 返り値 成功した場合、 \fBsigqueue\fP() は 0 を返す。 これは受け取り側プロセスの待ち行列に シグナルが正しく入れられたことを示す。 失敗した場合は \-1 が返され、 \fIerrno\fP がエラーを表す値に設定される。 .SH エラー .TP \fBEAGAIN\fP 待ち行列に入れられるシグナルの最大数に達した (より詳しい情報は \fBsignal\fP(7) を参照すること)。 .TP \fBEINVAL\fP \fIsig\fP が不正である。 .TP \fBEPERM\fP このプロセスには、受け取り側プロセスにシグナルを送る権限がない。 必要な権限については、 \fBkill\fP(2) を参照すること。 .TP \fBESRCH\fP \fIpid\fP にマッチする PID のプロセスがない。 .SH バージョン このシステムコールは Linux 2.2 で初めて登場した。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" \fBsigqueue\fP() 関数はスレッドセーフである。 .SH 準拠 POSIX.1\-2001. .SH 注意 この関数を呼び出したプロセスにこの関数がシグナルを送ったときに、 シグナルが呼び出し側スレッドにブロックされず、 かつ (シグナルがブロックされなかった、または \fBsigwait\fP(3) を使用するのを待っていることにより) このシグナルを扱うスレッドが何もない場合は、 この関数がリターンする前に、少なくとも そのスレッドに対してシグナルが配送されていなければならない。 Linux では、この関数は \fBrt_sigqueueinfo\fP(2) システムコールを使って実装されている。 両者には 3 番目の引き数に違いがあり、 \fBrt_sigqueueinfo\fP(2) では 3 番目の引き数は \fIsiginfo_t\fP 構造体である。 \fIsiginfo_t\fP 構造体は、シグナルを受信するプロセスのシグナルハンドラーに渡されたり、 シグナル受信プロセスの \fBsigtimedwait\fP(2) システムコールから返されたりする。 glibc の \fBsigqueue\fP() ラッパー関数内部では、 この引き数 \fIuinfo\fP は以下のように初期化される。 .in +4n .nf uinfo.si_signo = sig; /* Argument supplied to sigqueue() */ uinfo.si_code = SI_QUEUE; uinfo.si_pid = getpid(); /* Process ID of sender */ uinfo.si_uid = getuid(); /* Real UID of sender */ uinfo.si_value = val; /* Argument supplied to sigqueue() */ .fi .in .SH 関連項目 \fBkill\fP(2), \fBrt_sigqueueinfo\fP(2), \fBsigaction\fP(2), \fBsignal\fP(2), \fBpthread_sigqueue\fP(3), \fBsigwait\fP(3), \fBsignal\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部である。 プロジェクトの説明とバグ報告に関する情報は \%http://www.kernel.org/doc/man\-pages/ に書かれている。