OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[linuxjm/LDP_man-pages.git] / release / man2 / msgctl.2
1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
2 .\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
27 .\" Modified Sun Feb 18 01:59:29 2001 by Andries E. Brouwer <aeb@cwi.nl>
28 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\"     Added notes on CAP_IPC_OWNER requirement
30 .\" Modified, 17 Jun 2004, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Added notes on CAP_SYS_ADMIN requirement for IPC_SET and IPC_RMID
32 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\"     Language and formatting clean-ups
34 .\"     Added msqid_ds and ipc_perm structure definitions
35 .\" 2005-08-02, mtk: Added IPC_INFO, MSG_INFO, MSG_STAT descriptions
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" This file was generated with po4a. Translate the source file.
40 .\"
41 .\"*******************************************************************
42 .TH MSGCTL 2 2012\-05\-31 Linux "Linux Programmer's Manual"
43 .SH 名前
44 msgctl \- メッセージ制御操作
45 .SH 書式
46 .nf
47 \fB#include <sys/types.h>\fP
48 \fB#include <sys/ipc.h>\fP
49 \fB#include <sys/msg.h>\fP
50
51 \fBint msgctl(int \fP\fImsqid\fP\fB, int \fP\fIcmd\fP\fB, struct msqid_ds *\fP\fIbuf\fP\fB);\fP
52 .fi
53 .SH 説明
54 \fBmsgctl\fP()  はメッセージ・キュー識別子 \fImsqid\fP で指定されたメッセージ・キュー (message queue) に対して
55 \fIcmd\fP で指定された制御操作を行なう。
56 .PP
57 \fImsqid_ds\fP データ構造体は \fI<sys/msg.h>\fP で以下のように定義されている:
58 .nf
59 .in +4n
60
61 struct msqid_ds {
62     struct ipc_perm msg_perm;     /* 所有権と許可 */
63     time_t          msg_stime;    /* 最後の msgsnd(2) の時刻 */
64     time_t          msg_rtime;    /* 最後の msgrcv(2) の時刻 */
65     time_t          msg_ctime;    /* 最後に変更が行われた時刻 */
66     unsigned long   __msg_cbytes; /* キューにある現在のバイト数
67                                      (非標準) */
68     msgqnum_t       msg_qnum;     /* キューにある現在入っている
69                                      メッセージの数 */
70     msglen_t        msg_qbytes;   /* キューに許可されている
71                                      最大バイト数 */
72     pid_t           msg_lspid;    /* 最後の msgsnd(2) の PID */
73     pid_t           msg_lrpid;    /* 最後の msgrcv(2) の PID */
74 };
75 .in
76 .fi
77 .PP
78 The \fIipc_perm\fP structure is defined as follows (the highlighted fields are
79 settable using \fBIPC_SET\fP):
80 .PP
81 .nf
82 .in +4n
83 struct ipc_perm {
84     key_t          __key;       /* msgget(2) に与えるキー */
85     uid_t          \fBuid\fP;         /* 所有者の実効 UID */
86     gid_t          \fBgid\fP;         /* 所有者の実効 GID */
87     uid_t          cuid;        /* 作成者の実効 UID */
88     gid_t          cgid;        /* 作成者の実効 GID */
89     unsigned short \fBmode\fP;        /* 許可 */
90     unsigned short __seq;       /* シーケンス番号 */
91 };
92 .in
93 .fi
94 .PP
95 \fIcmd\fP として有効な値は:
96 .TP 
97 \fBIPC_STAT\fP
98 \fImsqid\fP に関連づけられたメッセージ・キュー・データ構造体から、ポインタ \fIbuf\fP が指し示す \fImsqid_ds\fP
99 構造体に情報をコピーする。 呼び出し側はメッセージ・キューに対する読み込み許可を持っていなければならない。
100 .TP 
101 \fBIPC_SET\fP
102 ポインタ \fIbuf\fP が指し示す \fImsqid_ds\fP 構造体のメンバーの値を、メッセージ・キューに関連づけられた
103 カーネル・データ構造体に書き込み、 \fImsg_ctime\fP メンバーも更新する。 構造体のメンバーのうち、更新されるものを以下に示す:
104 \fImsg_qbytes\fP, \fImsg_perm.uid\fP, \fImsg_perm.gid\fP, \fImsg_perm.mode\fP (の下位 9
105 ビット)。 呼び出したプロセスの実効ユーザ ID が、メッセージ・キューの所有者 (\fImsg_perm.uid\fP)  または作成者
106 (\fImsg_perm.cuid\fP)  と一致するか、呼び出し元が特権を持たなければならない。 \fImsg_qbytes\fP をシステム・パラメータの
107 \fBMSGMNB\fP を超えて設定するには、適切な特権 (Linux では \fBCAP_IPC_RESOURCE\fP ケーパビリティ
108 (capability)) が必要である。
109 .TP 
110 \fBIPC_RMID\fP
111 メッセージ・キューをただちに削除する。 同時にその構造体の読み書きの待ち状態にあったプロセスに通知する (エラーが返り、 \fIerrno\fP が
112 \fBEIDRM\fP に設定される)。 呼び出したプロセスが適切な特権を持っているか、 呼び出したプロセスの実効ユーザ ID がメッセージ・キューの作成者か
113 所有者の実効ユーザ ID でなければならない。
114 .TP 
115 \fBIPC_INFO\fP (Linux 固有)
116 システム全体でのメッセージ・キューの制限とパラメータに関する情報を、 \fIbuf\fP が指す構造体に入れて返す。 この構造体は \fImsginfo\fP
117 型である (そのためキャストが必要である)。 \fImsginfo\fP は \fB_GNU_SOURCE\fP 機能検査マクロが定義された場合に
118 \fI<sys/msg.h>\fP で以下のように定義される:
119 .nf
120 .in +4n
121
122 struct msginfo {
123     int msgpool; /* メッセージ・データの保持に使用される
124                     バッファ・プールの大きさ (1024 バイト単位);
125                     カーネル内では未使用 */
126     int msgmap;  /* メッセージ・マップの最大エントリ数;
127                     カーネル内では未使用 */
128     int msgmax;  /* 一つのメッセージに書き込み可能な
129                     最大バイト数 */
130     int msgmnb;  /* 一つのキューに書き込み可能な最大バイト数;
131                     (msgget(2) での) キュー作成中の msg_qbytes
132                     の初期化に使用される */
133     int msgmni;  /* メッセージ・キューの数の最大値 */
134     int msgssz;  /* メッセージ・セグメントのサイズ;
135                     カーネル内では未使用 */
136     int msgtql;  /* システム上の全キューの最大メッセージ数;
137                     カーネル内では未使用 */
138     unsigned short int msgseg;
139                  /* 最大セグメント数; カーネル内では未使用 */
140 };
141
142 .in
143 .fi
144 設定 \fImsgmni ,\fP \fImsgmax ,\fP \fImsgmnb\fP は \fI/proc\fP にある同じ名前のファイル経由で変更可能である。 詳しくは
145 \fBproc\fP(5)  を参照。
146 .TP 
147 \fBMSG_INFO\fP (Linux 固有)
148 \fBIPC_INFO\fP のときと同じ情報を格納した \fImsginfo\fP 構造体を返す。 但し、以下のフィールドにはメッセージ・キューが
149 消費しているシステム資源に関する情報が格納される点が異なる。 \fImsgpool\fP フィールドは現在システム上に存在するメッセージ・キューの数を返す。
150 \fImsgmap\fP フィールドはシステム上の全てのキューに入っているメッセージ総数を返す。 \fImsgtql\fP
151 フィールドはシステム上の全てのキューに入っている全メッセージの 総バイト数を返す。
152 .TP 
153 \fBMSG_STAT\fP (Linux 固有)
154 \fBIPC_STAT\fP と同じく \fImsqid_ds\fP 構造体を返す。 但し、 \fImsqid\fP
155 引き数は、キュー識別子ではなく、システム上の全てのメッセージ・キュー に関する情報を管理するカーネルの内部配列へのインデックスである。
156 .SH 返り値
157 成功すると、 \fBIPC_STAT\fP, \fBIPC_SET\fP, \fBIPC_RMID\fP は 0 を返す。 \fBIPC_INFO\fP と
158 \fBMSG_INFO\fP 操作は、成功すると、全てのメッセージ・キューに関する情報を 管理しているカーネルの内部配列の使用中エントリのインデックスの
159 うち最大値を返す (この情報は、システムの全てのメッセージ・キューに関する情報を 取得するために、 \fBMSG_STAT\fP
160 操作を繰り返し実行する際に使用できる)。 \fBMSG_STAT\fP 操作は、成功すると、 \fImsqid\fP
161 で指定されたインデックスを持つメッセージ・キューの識別子を返す。
162
163 エラーの場合は \-1 を返し、 \fIerrno\fP を適切に設定する。
164 .SH エラー
165 失敗した場合、 \fIerrno\fP は以下の値の中のどれか一つに設定される:
166 .TP 
167 \fBEACCES\fP
168 引き数 \fIcmd\fP が \fBIPC_STAT\fP または \fBMSG_STAT\fP に等しいが、呼び出したプロセスがメッセージ・キュー \fImsqid\fP
169 に対する読み込み許可を持っておらず、かつ \fBCAP_IPC_OWNER\fP ケーパビリティを持っていない。
170 .TP 
171 \fBEFAULT\fP
172 引き数 \fIcmd\fP が \fBIPC_SET\fP か \fBIPC_STAT\fP で、ポインタ \fIbuf\fP で指されているアドレスがアクセス可能でない。
173 .TP 
174 \fBEIDRM\fP
175 メッセージ・キューが削除された。
176 .TP 
177 \fBEINVAL\fP
178 \fIcmd\fP または \fImsqid\fP に不正な値が設定された。 もしくは、 \fBMSG_STAT\fP 操作の場合に、 \fImsqid\fP
179 で指定されたインデックス値が現在未使用の配列のスロットを参照いていた。
180 .TP 
181 \fBEPERM\fP
182 引き数 \fIcmd\fP が \fBIPC_SET\fP か \fBIPC_RMID\fP であるが、呼び出したプロセスの実効ユーザ ID がメッセージキューの
183 (\fImsg_perm.cuid\fP として見つかる) 作成者 と (\fImsg_perm.uid\fP として見つかる) 所有者のいずれでもなく、
184 かつ呼び出したプロセスに特権 (Linux では \fBCAP_SYS_ADMIN\fP ケーパビリティ) がない。
185 .SH 準拠
186 .\" SVID does not document the EIDRM error condition.
187 SVr4, POSIX.1\-2001.
188 .SH 注意
189 .\" Like Linux, the FreeBSD man pages still document
190 .\" the inclusion of these header files.
191 The inclusion of \fI<sys/types.h>\fP and \fI<sys/ipc.h>\fP isn't
192 required on Linux or by any version of POSIX.  However, some old
193 implementations required the inclusion of these header files, and the SVID
194 also documented their inclusion.  Applications intended to be portable to
195 such old systems may need to include these header files.
196
197 \fBIPC_INFO\fP, \fBMSG_STAT\fP, \fBMSG_INFO\fP 操作は、 \fBipcs\fP(1)
198 プログラムで割り当て済の資源に関する情報を提供するために 使用されている。将来、これらの操作は変更されたり、 /proc
199 ファイルシステムのインタフェースに移動されるかもしれない。
200
201 \fIstruct msqid_ds\fP 内の多くのフィールドは、 Linux 2.2 では \fIshort\fP だったが、Linux 2.4 では
202 \fIlong\fP になった。 この利点を生かすには、glibc\-2.1.91 以降の環境下で 再コンパイルすれば十分である。
203 (カーネルは新しい形式の呼び出しと古い形式の呼び出しを \fIcmd\fP 内の \fBIPC_64\fP フラグで区別する。)
204 .SH 関連項目
205 \fBmsgget\fP(2), \fBmsgrcv\fP(2), \fBmsgsnd\fP(2), \fBcapabilities\fP(7),
206 \fBmq_overview\fP(7), \fBsvipc\fP(7)
207 .SH この文書について
208 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
209 である。プロジェクトの説明とバグ報告に関する情報は
210 http://www.kernel.org/doc/man\-pages/ に書かれている。