OSDN Git Service

LDP: Update draft based on the previous commit
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / mq_open.3
1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\"*******************************************************************
26 .\"
27 .\" This file was generated with po4a. Translate the source file.
28 .\"
29 .\"*******************************************************************
30 .\"
31 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
32 .\" Translated 2006-04-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
33 .\"
34 .TH MQ_OPEN 3 2020\-08\-13 Linux "Linux Programmer's Manual"
35 .SH 名前
36 mq_open \- メッセージキューをオープンする
37 .SH 書式
38 .nf
39 \fB#include <fcntl.h>\fP           /* For O_* constants */
40 \fB#include <sys/stat.h>\fP        /* For mode constants */
41 \fB#include <mqueue.h>\fP
42 .PP
43 \fBmqd_t mq_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB);\fP
44 \fBmqd_t mq_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB, mode_t \fP\fImode\fP\fB,\fP
45 \fB              struct mq_attr *\fP\fIattr\fP\fB);\fP
46 .fi
47 .PP
48 \fI\-lrt\fP でリンクする。
49 .SH 説明
50 \fBmq_open\fP()  は、新しい POSIX メッセージキューを作成するか、既存のキューを オープンする。キューは \fIname\fP で識別される。
51 \fIname\fP の構成の詳細については \fBmq_overview (7)\fP を参照。
52 .PP
53 \fIoflag\fP 引き数には、関数呼び出しの操作を制御するフラグを指定する (oflag の値の定義は \fI<fcntl.h>\fP
54 のインクルードにより得られる)。 \fIoflag\fP には、以下のうちいずれか一つを必ず指定しなければならない。
55 .TP 
56 \fBO_RDONLY\fP
57 メッセージの受信専用としてキューをオープンする。
58 .TP 
59 \fBO_WRONLY\fP
60 メッセージの送信専用としてキューをオープンする。
61 .TP 
62 \fBO_RDWR\fP
63 メッセージの送受信両用としてキューをオープンする。
64 .PP
65 0 個以上の下記のフラグを、ビット単位の OR (論理和) で \fIoflag\fP に追加で指定できる。
66 .TP 
67 \fBO_CLOEXEC\fP (Linux 2.6.26 以降)
68 .\" commit 269f21344b23e552c21c9e2d7ca258479dcd7a0a
69 メッセージキュー記述子に close\-on\-exec フラグをセットする。 なぜこのフラグが有用かについての議論は \fBopen\fP(2) を参照。
70 .TP 
71 \fBO_CREAT\fP
72 .\" In reality the filesystem IDs are used on Linux.
73 存在しない場合、メッセージキューを作成する。 メッセージキューの所有者 (ユーザー ID) とグループ所有権 (グループ ID) は、
74 それぞれ呼び出し元プロセスの実効ユーザー ID と実効グループ ID に設定される。
75 .TP 
76 \fBO_EXCL\fP
77 \fBO_CREAT\fP が \fIoflag\fP に指定され、かつ指定された名前 \fIname\fP を持つキューがすでに存在する場合、エラー \fBEEXIST\fP
78 で失敗する。
79 .TP 
80 \fBO_NONBLOCK\fP
81 非停止 (nonblocking) モードでキューをオープンする。 \fBmq_receive\fP(3)  と \fBmq_send\fP(3)  は、通常は停止
82 (block) する状況において、エラー \fBEAGAIN\fP で失敗するようになる。
83 .PP
84 \fIoflag\fP に \fBO_CREAT\fP を指定する場合、追加で 2つの引き数を与える必要がある。 \fImode\fP
85 引き数は、新しいキューに適用される許可設定 (permission) を、 \fBopen\fP(2)  と同じように指定する (許可ビットのシンボル定義は
86 \fI<sys/stat.h>\fP のインクルードにより得られる)。 許可設定はプロセスの umask でマスクされる。
87 .PP
88 The fields of the \fIstruct mq_attr\fP pointed to \fIattr\fP specify the maximum
89 number of messages and the maximum size of messages that the queue will
90 allow.  This structure is defined as follows:
91 .PP
92 .in +4n
93 .EX
94 struct mq_attr {
95     long mq_flags;       /* Flags (ignored for mq_open()) */
96     long mq_maxmsg;      /* Max. # of messages on queue */
97     long mq_msgsize;     /* Max. message size (bytes) */
98     long mq_curmsgs;     /* # of messages currently in queue
99                             (ignored for mq_open()) */
100 };
101 .EE
102 .in
103 .PP
104 Only the \fImq_maxmsg\fP and \fImq_msgsize\fP fields are employed when calling
105 \fBmq_open\fP(); the values in the remaining fields are ignored.
106 .PP
107 If \fIattr\fP is NULL, then the queue is created with implementation\-defined
108 default attributes.  Since Linux 3.5, two \fI/proc\fP files can be used to
109 control these defaults; see \fBmq_overview\fP(7)  for details.
110 .SH 返り値
111 成功すると、 \fBmq_open\fP()  はメッセージキュー記述子 (message queue descriptor) を返す。
112 メッセージキュー記述子は他のメッセージキュー関連の関数で使用される。 エラーの場合、 \fBmq_open\fP()  は \fI(mqd_t)\ \-1\fP
113 を返し、 \fIerrno\fP にエラーを示す値を設定する。
114 .SH エラー
115 .TP 
116 \fBEACCES\fP
117 キューは存在するが、呼び出し元が指定されたモードでそのキュー をオープンする許可を持たない。
118 .TP 
119 \fBEACCES\fP
120 .\" Note that this isn't consistent with the same case for sem_open()
121 \fIname\fP にスラッシュが 2 個以上含まれていた。
122 .TP 
123 \fBEEXIST\fP
124 \fIoflag\fP に \fBO_CREAT\fP と \fBO_EXCL\fP の両方が指定されたが、指定された名前 \fIname\fP を持つキューがすでに存在する。
125 .TP 
126 \fBEINVAL\fP
127 .\" glibc checks whether the name starts with a "/" and if not,
128 .\" gives this error
129 \fIname\fP doesn't follow the format in \fBmq_overview\fP(7).
130 .TP 
131 \fBEINVAL\fP
132 \fIoflag\fP に \fBO_CREAT\fP が指定され、かつ \fIattr\fP が NULL 以外だが、 \fIattr\->mq_maxmsg\fP か
133 \fIattr\->mq_msqsize\fP が不正であった。 これらのフィールドは両方とも 0 より大きくなければならない。
134 プロセスが特権を持たない (\fBCAP_SYS_RESOURCE\fP ケーパビリティを持たない) 場合、 \fIattr\->mq_maxmsg\fP と
135 \fIattr\->mq_msgsize\fP は、それぞれ上限 \fImsg_max\fP、 \fImsgsize_max\fP 以下でなければならない。
136 また、特権プロセスの場合でも、 \fIattr\->mq_maxmsg\fP は \fBHARD_MAX\fP 上限を超えることはできない。
137 (これらの上限に関する詳細は \fBmq_overview\fP(7)  を参照。)
138 .TP 
139 \fBEMFILE\fP
140 The per\-process limit on the number of open file and message queue
141 descriptors has been reached (see the description of \fBRLIMIT_NOFILE\fP in
142 \fBgetrlimit\fP(2)).
143 .TP 
144 \fBENAMETOOLONG\fP
145 \fIname\fP が長過ぎる。
146 .TP 
147 \fBENFILE\fP
148 The system\-wide limit on the total number of open files and message queues
149 has been reached.
150 .TP 
151 \fBENOENT\fP
152 \fBO_CREAT\fP フラグが \fIoflag\fP に指定されなかったが、指定された名前 \fIname\fP を持つキューが存在しない。
153 .TP 
154 \fBENOENT\fP
155 .\" Note that this isn't consistent with the same case for sem_open()
156 \fIname\fP が "/" だけで、その後ろに他の文字が続いていなかった。
157 .TP 
158 \fBENOMEM\fP
159 十分なメモリーがない。
160 .TP 
161 \fBENOSPC\fP
162 新しいメッセージキューを作成するのに十分な空間がない。 このエラーはおそらく \fIqueues_max\fP 上限に抵触したため起こったのだろう。
163 \fBmq_overview\fP(7)  を参照。
164 .SH 属性
165 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
166 .TS
167 allbox;
168 lb lb lb
169 l l l.
170 インターフェース        属性  値
171 T{
172 \fBmq_open\fP()
173 T}      Thread safety   MT\-Safe
174 .TE
175 .SH 準拠
176 POSIX.1\-2001, POSIX.1\-2008.
177 .SH 注意
178 .SS "C library/kernel differences"
179 The \fBmq_open\fP()  library function is implemented on top of a system call of
180 the same name.  The library function performs the check that the \fIname\fP
181 starts with a slash (/), giving the \fBEINVAL\fP error if it does not.  The
182 kernel system call expects \fIname\fP to contain no preceding slash, so the C
183 library function passes \fIname\fP without the preceding slash (i.e.,
184 \fIname+1\fP)  to the system call.
185 .SH バグ
186 2.6.14 より前のカーネルには、 プロセスの umask が \fImode\fP で指定された許可設定に適用されなかった。
187 .SH 関連項目
188 \fBmq_close\fP(3), \fBmq_getattr\fP(3), \fBmq_notify\fP(3), \fBmq_receive\fP(3),
189 \fBmq_send\fP(3), \fBmq_unlink\fP(3), \fBmq_overview\fP(7)
190 .SH この文書について
191 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
192 \%https://www.kernel.org/doc/man\-pages/ に書かれている。