OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / mq_open.3
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
27 .\" Translated 2006-04-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\"
29 .TH MQ_OPEN 3 2009-02-20 "Linux" "Linux Programmer's Manual"
30 .\"O .SH NAME
31 .SH Ì¾Á°
32 .\"O mq_open \- open a message queue
33 mq_open \- ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë
34 .\"O .SH SYNOPSIS
35 .SH ½ñ¼°
36 .nf
37 .BR "#include <fcntl.h>" "           /* For O_* constants */"
38 .BR "#include <sys/stat.h>" "        /* For mode constants */"
39 .B #include <mqueue.h>
40 .sp
41 .BI "mqd_t mq_open(const char *" name ", int " oflag );
42 .BI "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode ,
43 .BI "              struct mq_attr *" attr );
44 .fi
45 .sp
46 .\"O Link with \fI\-lrt\fP.
47 \fI\-lrt\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
48 .\"O .SH DESCRIPTION
49 .SH ÀâÌÀ
50 .\"O .BR mq_open ()
51 .\"O creates a new POSIX message queue or opens an existing queue.
52 .\"O The queue is identified by
53 .\"O .IR name .
54 .\"O For details of the construction of
55 .\"O .IR name ,
56 .\"O see
57 .\"O .BR mq_overview (7).
58 .BR mq_open ()
59 ¤Ï¡¢¿·¤·¤¤ POSIX ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤òºîÀ®¤¹¤ë¤«¡¢´û¸¤Î¥­¥å¡¼¤ò
60 ¥ª¡¼¥×¥ó¤¹¤ë¡£¥­¥å¡¼¤Ï
61 .I name
62 ¤Ç¼±Ê̤µ¤ì¤ë¡£
63 .I name
64 ¤Î¹½À®¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï
65 .B mq_overview (7)
66 ¤ò»²¾È¡£
67
68 .\"O The
69 .\"O .I oflag
70 .\"O argument specifies flags that control the operation of the call.
71 .\"O (Definitions of the flags values can be obtained by including
72 .\"O .IR <fcntl.h> .)
73 .\"O Exactly one of the following must be specified in
74 .\"O .IR oflag :
75 .I oflag
76 °ú¤­¿ô¤Ë¤Ï¡¢´Ø¿ô¸Æ¤Ó½Ð¤·¤ÎÁàºî¤òÀ©¸æ¤¹¤ë¥Õ¥é¥°¤ò»ØÄꤹ¤ë
77 (oflag ¤ÎÃͤÎÄêµÁ¤Ï
78 .I <fcntl.h>
79 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë)¡£
80 .I oflag
81 ¤Ë¤Ï¡¢°Ê²¼¤Î¤¦¤Á¤¤¤º¤ì¤«°ì¤Ä¤òɬ¤º»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
82 .TP
83 .B O_RDONLY
84 .\"O Open the queue to receive messages only.
85 ¥á¥Ã¥»¡¼¥¸¤Î¼õ¿®ÀìÍѤȤ·¤Æ¥­¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
86 .TP
87 .B O_WRONLY
88 .\"O Open the queue to send messages only.
89 ¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®ÀìÍѤȤ·¤Æ¥­¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
90 .TP
91 .B O_RDWR
92 .\"O Open the queue to both send and receive messages.
93 ¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¼õ¿®Î¾ÍѤȤ·¤Æ¥­¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
94 .PP
95 .\"O Zero or more of the following flags can additionally be
96 .\"O .IR OR ed
97 .\"O in
98 .\"O .IR oflag :
99 0 ¸Ä°Ê¾å¤Î²¼µ­¤Î¥Õ¥é¥°¤ò¡¢¥Ó¥Ã¥Èñ°Ì¤Î OR (ÏÀÍýÏÂ) ¤Ç
100 .I oflag
101 ¤ËÄɲäǻØÄê¤Ç¤­¤ë¡£
102 .TP
103 .B O_NONBLOCK
104 .\"O Open the queue in nonblocking mode.
105 .\"O In circumstances where
106 .\"O .BR mq_receive (3)
107 .\"O and
108 .\"O .BR mq_send (3)
109 .\"O would normally block, these functions instead fail with the error
110 .\"O .BR EAGAIN .
111 ÈóÄä»ß (nonblocking) ¥â¡¼¥É¤Ç¥­¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
112 .BR mq_receive (3)
113 ¤È
114 .BR mq_send (3)
115 ¤Ï¡¢Ä̾ï¤ÏÄä»ß (block) ¤¹¤ë¾õ¶·¤Ë¤ª¤¤¤Æ¡¢¥¨¥é¡¼
116 .B EAGAIN
117 ¤Ç¼ºÇÔ¤¹¤ë¤è¤¦¤Ë¤Ê¤ë¡£
118 .TP
119 .B O_CREAT
120 .\"O Create the message queue if it does not exist.
121 .\"O The owner (user ID) of the message queue is set to the effective
122 .\"O user ID of the calling process.
123 .\"O The group ownership (group ID) is set to the effective group ID
124 .\"O of the calling process.
125 .\"O .\" In reality the file system IDs are used on Linux.
126 ¸ºß¤·¤Ê¤¤¾ì¹ç¡¢¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤òºîÀ®¤¹¤ë¡£
127 ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤Î½êÍ­¼Ô (¥æ¡¼¥¶ ID) ¤È¥°¥ë¡¼¥×½êÍ­¸¢ (¥°¥ë¡¼¥× ID) ¤Ï¡¢
128 ¤½¤ì¤¾¤ì¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú¥æ¡¼¥¶ ID ¤È¼Â¸ú¥°¥ë¡¼¥× ID ¤ËÀßÄꤵ¤ì¤ë¡£
129 .\" ¼ÂºÝ¤Ï¡¢Linux ¤Ç¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à ID ¤¬»ÈÍѤµ¤ì¤ë¡£
130 .TP
131 .B O_EXCL
132 .\"O If
133 .\"O .B O_CREAT
134 .\"O was specified in
135 .\"O .IR oflag ,
136 .\"O and a queue with the given
137 .\"O .I name
138 .\"O already exists, then fail with the error
139 .\"O .BR EEXIST .
140 .B O_CREAT
141 ¤¬
142 .I oflag
143 ¤Ë»ØÄꤵ¤ì¡¢¤«¤Ä»ØÄꤵ¤ì¤¿Ì¾Á°
144 .I name
145 ¤ò»ý¤Ä¥­¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢¥¨¥é¡¼
146 .B EEXIST
147 ¤Ç¼ºÇÔ¤¹¤ë¡£
148 .PP
149 .\"O If
150 .\"O .B O_CREAT
151 .\"O is specified in
152 .\"O .IR oflag ,
153 .\"O then two additional arguments must be supplied.
154 .I oflag
155 ¤Ë
156 .B O_CREAT
157 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢ÄɲäǠ2¤Ä¤Î°ú¤­¿ô¤òÍ¿¤¨¤ëɬÍפ¬¤¢¤ë¡£
158 .\"O The
159 .\"O .I mode
160 .\"O argument specifies the permissions to be placed on the new queue,
161 .\"O as for
162 .\"O .BR open (2).
163 .\"O (Symbolic definitions for the permissions bits can be obtained by including
164 .\"O .IR <sys/stat.h> .)
165 .\"O The permissions settings are masked against the process umask.
166 .I mode
167 °ú¤­¿ô¤Ï¡¢¿·¤·¤¤¥­¥å¡¼¤ËŬÍѤµ¤ì¤ëµö²ÄÀßÄê (permission) ¤ò¡¢
168 .BR open (2)
169 ¤ÈƱ¤¸¤è¤¦¤Ë»ØÄꤹ¤ë
170 (µö²Ä¥Ó¥Ã¥È¤Î¥·¥ó¥Ü¥ëÄêµÁ¤Ï
171 .I <sys/stat.h>
172 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë)¡£
173 µö²ÄÀßÄê¤Ï¥×¥í¥»¥¹¤Î umask ¤Ç¥Þ¥¹¥¯¤µ¤ì¤ë¡£
174 .\"O The
175 .\"O .I attr
176 .\"O argument specifies attributes for the queue.
177 .\"O See
178 .\"O .BR mq_getattr (3)
179 .\"O for details.
180 .\"O If
181 .\"O .I attr
182 .\"O is NULL, then the queue is created with implementation-defined
183 .\"O default attributes.
184 .I attr
185 °ú¤­¿ô¤Ï¡¢¥­¥å¡¼¤Î°À­¤ò»ØÄꤹ¤ë¡£¾ÜºÙ¤Ï¡¢
186 .BR mq_getattr (3)
187 ¤ò»²¾È¡£
188 .I attr
189 ¤¬ NULL ¤Î¾ì¹ç¡¢¥­¥å¡¼¤Ï¼ÂÁõ¤ÇÄêµÁ¤µ¤ì¤¿¥Ç¥Õ¥©¥ë¥È°À­¤ÇºîÀ®¤µ¤ì¤ë¡£
190 .\"O .SH RETURN VALUE
191 .SH ÊÖ¤êÃÍ
192 .\"O On success,
193 .\"O .BR mq_open ()
194 .\"O returns a message queue descriptor for use by other
195 .\"O message queue functions.
196 À®¸ù¤¹¤ë¤È¡¢
197 .BR mq_open ()
198 ¤Ï¥á¥Ã¥»¡¼¥¸¥­¥å¡¼µ­½Ò»Ò (message queue descriptor) ¤òÊÖ¤¹¡£
199 ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼µ­½Ò»Ò¤Ï¾¤Î¥á¥Ã¥»¡¼¥¸¥­¥å¡¼´ØÏ¢¤Î´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£
200 .\"O On error,
201 .\"O .BR mq_open ()
202 .\"O returns
203 .\"O .IR "(mqd_t)\ \-1",
204 .\"O with
205 .\"O .I errno
206 .\"O set to indicate the error.
207 ¥¨¥é¡¼¤Î¾ì¹ç¡¢
208 .BR mq_open ()
209 ¤Ï
210 .I "(mqd_t)\ \-1"
211 ¤òÊÖ¤·¡¢
212 .I errno
213 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
214 .\"O .SH ERRORS
215 .SH ¥¨¥é¡¼
216 .TP
217 .B EACCES
218 .\"O The queue exists, but the caller does not have permission to
219 .\"O open it in the specified mode.
220 ¥­¥å¡¼¤Ï¸ºß¤¹¤ë¤¬¡¢¸Æ¤Ó½Ð¤·¸µ¤¬»ØÄꤵ¤ì¤¿¥â¡¼¥É¤Ç¤½¤Î¥­¥å¡¼
221 ¤ò¥ª¡¼¥×¥ó¤¹¤ëµö²Ä¤ò»ý¤¿¤Ê¤¤¡£
222 .TP
223 .B EACCES
224 .\"O .I name
225 .\"O contained more than one slash.
226 .I name
227 ¤Ë¥¹¥é¥Ã¥·¥å¤¬ 2 ¸Ä°Ê¾å´Þ¤Þ¤ì¤Æ¤¤¤¿¡£
228 .\" Note that this isn't consistent with the same case for sem_open()
229 .TP
230 .B EEXIST
231 .\"O Both
232 .\"O .B O_CREAT
233 .\"O and
234 .\"O .B O_EXCL
235 .\"O were specified in
236 .\"O .IR oflag ,
237 .\"O but a queue with this
238 .\"O .I name
239 .\"O already exists.
240 .I oflag
241 ¤Ë
242 .B O_CREAT
243 ¤È
244 .B O_EXCL
245 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¤¬¡¢»ØÄꤵ¤ì¤¿Ì¾Á°
246 .I name
247 ¤ò»ý¤Ä¥­¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¡£
248 .TP
249 .B EINVAL
250 .\"O .B O_CREAT
251 .\"O was specified in
252 .\"O .IR oflag ,
253 .\"O and
254 .\"O .I attr
255 .\"O was not NULL, but
256 .\"O .I attr\->mq_maxmsg
257 .\"O or
258 .\"O .I attr\->mq_msqsize
259 .\"O was invalid.
260 .\"O Both of these fields must be greater than zero.
261 .I oflag
262 ¤Ë
263 .B O_CREAT
264 ¤¬»ØÄꤵ¤ì¡¢¤«¤Ä
265 .I attr
266 ¤¬ NULL °Ê³°¤À¤¬¡¢
267 .I attr\->mq_maxmsg
268 ¤«
269 .I attr\->mq_msqsize
270 ¤¬ÉÔÀµ¤Ç¤¢¤Ã¤¿¡£
271 ¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤ÏξÊý¤È¤â 0 ¤è¤êÂ礭¤¯¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
272 .\"O In a process that is unprivileged (does not have the
273 .\"O .B CAP_SYS_RESOURCE
274 .\"O capability),
275 .\"O .I attr\->mq_maxmsg
276 .\"O must be less than or equal to the
277 .\"O .I msg_max
278 .\"O limit, and
279 .\"O .I attr\->mq_msgsize
280 .\"O must be less than or equal to the
281 .\"O .I msgsize_max
282 .\"O limit.
283 .\"O In addition, even in a privileged process,
284 .\"O .I attr\->mq_maxmsg
285 .\"O cannot exceed the
286 .\"O .B HARD_MAX
287 .\"O limit.
288 .\"O (See
289 .\"O .BR mq_overview (7)
290 .\"O for details of these limits.)
291 ¥×¥í¥»¥¹¤¬Æø¢¤ò»ý¤¿¤Ê¤¤
292 .RB ( CAP_SYS_RESOURCE
293 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤¿¤Ê¤¤) ¾ì¹ç¡¢
294 .I attr\->mq_maxmsg
295 ¤È
296 .I attr\->mq_msgsize
297 ¤Ï¡¢¤½¤ì¤¾¤ì¾å¸Â
298 .IR msg_max ¡¢
299 .I msgsize_max
300 °Ê²¼¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
301 ¤Þ¤¿¡¢Æø¢¥×¥í¥»¥¹¤Î¾ì¹ç¤Ç¤â¡¢
302 .I attr\->mq_maxmsg
303 ¤Ï
304 .B HARD_MAX
305 ¾å¸Â¤òĶ¤¨¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
306 (¤³¤ì¤é¤Î¾å¸Â¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ï
307 .BR mq_overview (7)
308 ¤ò»²¾È¡£)
309 .TP
310 .B EMFILE
311 .\"O The process already has the maximum number of files and
312 .\"O message queues open.
313 ¤½¤Î¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤È¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤Î¿ô¤¬
314 ¥×¥í¥»¥¹Ëè¤Î¾å¸Â¤Ë㤷¤Æ¤¤¤ë¡£
315 .TP
316 .B ENAMETOOLONG
317 .\"O .I name
318 .\"O was too long.
319 .I name
320 ¤¬Ä¹¤¹¤®¤ë¡£
321 .TP
322 .B ENFILE
323 .\"O The system limit on the total number of open files and message queues
324 .\"O has been reached.
325 ¥·¥¹¥Æ¥àÁ´ÂΤǥª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤È¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤Î¹ç·×¿ô¤¬
326 ¥·¥¹¥Æ¥à¾å¸Â¤Ë㤷¤Æ¤¤¤ë¡£
327 .TP
328 .B ENOENT
329 .\"O The
330 .\"O .B O_CREAT
331 .\"O flag was not specified in
332 .\"O .IR oflag ,
333 .\"O and no queue with this
334 .\"O .I name
335 .\"O exists.
336 .B O_CREAT
337 ¥Õ¥é¥°¤¬
338 .I oflag
339 ¤Ë»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¤¬¡¢»ØÄꤵ¤ì¤¿Ì¾Á°
340 .I name
341 ¤ò»ý¤Ä¥­¥å¡¼¤¬Â¸ºß¤·¤Ê¤¤¡£
342 .TP
343 .B ENOENT
344 .\"O .I name
345 .\"O was just "/" followed by no other characters.
346 .I name
347 ¤¬ "/" ¤À¤±¤Ç¡¢¤½¤Î¸å¤í¤Ë¾¤Îʸ»ú¤¬Â³¤¤¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
348 .\" Note that this isn't consistent with the same case for sem_open()
349 .TP
350 .B ENOMEM
351 .\"O Insufficient memory.
352 ½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
353 .TP
354 .B ENOSPC
355 .\"O Insufficient space for the creation of a new message queue.
356 .\"O This probably occurred because the
357 .\"O .I queues_max
358 .\"O limit was encountered; see
359 .\"O .BR mq_overview (7).
360 ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤òºîÀ®¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¶õ´Ö¤¬¤Ê¤¤¡£
361 ¤³¤Î¥¨¥é¡¼¤Ï¤ª¤½¤é¤¯
362 .I queues_max
363 ¾å¸Â¤ËÄñ¿¨¤·¤¿¤¿¤áµ¯¤³¤Ã¤¿¤Î¤À¤í¤¦¡£
364 .BR mq_overview (7)
365 ¤ò»²¾È¡£
366 .\"O .SH CONFORMING TO
367 .SH ½àµò
368 POSIX.1-2001.
369 .\"O .SH BUGS
370 .SH ¥Ð¥°
371 .\"O In kernels before 2.6.14,
372 .\"O the process umask was not applied to the permissions specified in
373 .\"O .IR mode .
374 2.6.14 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ë¤Ï¡¢
375 ¥×¥í¥»¥¹¤Î umask ¤¬
376 .I mode
377 ¤Ç»ØÄꤵ¤ì¤¿µö²ÄÀßÄê¤ËŬÍѤµ¤ì¤Ê¤«¤Ã¤¿¡£
378 .\"O .SH "SEE ALSO"
379 .SH ´ØÏ¢¹àÌÜ
380 .BR mq_close (3),
381 .BR mq_getattr (3),
382 .BR mq_notify (3),
383 .BR mq_receive (3),
384 .BR mq_send (3),
385 .BR mq_unlink (3),
386 .BR mq_overview (7)