2 .\" Hey Emacs! This file is -*- nroff -*- source.
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
27 .\" Translated 2006-04-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
29 .TH MQ_OPEN 3 2009-02-20 "Linux" "Linux Programmer's Manual"
32 .\"O mq_open \- open a message queue
33 mq_open \- ¥á¥Ã¥»¡¼¥¸¥¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë
37 .BR "#include <fcntl.h>" " /* For O_* constants */"
38 .BR "#include <sys/stat.h>" " /* For mode constants */"
39 .B #include <mqueue.h>
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 );
46 .\"O Link with \fI\-lrt\fP.
47 \fI\-lrt\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
51 .\"O creates a new POSIX message queue or opens an existing queue.
52 .\"O The queue is identified by
54 .\"O For details of the construction of
57 .\"O .BR mq_overview (7).
59 ¤Ï¡¢¿·¤·¤¤ POSIX ¥á¥Ã¥»¡¼¥¸¥¥å¡¼¤òºîÀ®¤¹¤ë¤«¡¢´û¸¤Î¥¥å¡¼¤ò
60 ¥ª¡¼¥×¥ó¤¹¤ë¡£¥¥å¡¼¤Ï
64 ¤Î¹½À®¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï
70 .\"O argument specifies flags that control the operation of the call.
71 .\"O (Definitions of the flags values can be obtained by including
73 .\"O Exactly one of the following must be specified in
76 °ú¤¿ô¤Ë¤Ï¡¢´Ø¿ô¸Æ¤Ó½Ð¤·¤ÎÁàºî¤òÀ©¸æ¤¹¤ë¥Õ¥é¥°¤ò»ØÄꤹ¤ë
79 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë)¡£
81 ¤Ë¤Ï¡¢°Ê²¼¤Î¤¦¤Á¤¤¤º¤ì¤«°ì¤Ä¤òɬ¤º»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
84 .\"O Open the queue to receive messages only.
85 ¥á¥Ã¥»¡¼¥¸¤Î¼õ¿®ÀìÍѤȤ·¤Æ¥¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
88 .\"O Open the queue to send messages only.
89 ¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®ÀìÍѤȤ·¤Æ¥¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
92 .\"O Open the queue to both send and receive messages.
93 ¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¼õ¿®Î¾ÍѤȤ·¤Æ¥¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
95 .\"O Zero or more of the following flags can additionally be
99 0 ¸Ä°Ê¾å¤Î²¼µ¤Î¥Õ¥é¥°¤ò¡¢¥Ó¥Ã¥Èñ°Ì¤Î OR (ÏÀÍýÏÂ) ¤Ç
104 .\"O Open the queue in nonblocking mode.
105 .\"O In circumstances where
106 .\"O .BR mq_receive (3)
109 .\"O would normally block, these functions instead fail with the error
111 ÈóÄä»ß (nonblocking) ¥â¡¼¥É¤Ç¥¥å¡¼¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
115 ¤Ï¡¢Ä̾ï¤ÏÄä»ß (block) ¤¹¤ë¾õ¶·¤Ë¤ª¤¤¤Æ¡¢¥¨¥é¡¼
117 ¤Ç¼ºÇÔ¤¹¤ë¤è¤¦¤Ë¤Ê¤ë¡£
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 ¤¬»ÈÍѤµ¤ì¤ë¡£
134 .\"O was specified in
136 .\"O and a queue with the given
138 .\"O already exists, then fail with the error
143 ¤Ë»ØÄꤵ¤ì¡¢¤«¤Ä»ØÄꤵ¤ì¤¿Ì¾Á°
145 ¤ò»ý¤Ä¥¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢¥¨¥é¡¼
153 .\"O then two additional arguments must be supplied.
157 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢ÄÉ²Ã¤Ç 2¤Ä¤Î°ú¤¿ô¤òÍ¿¤¨¤ëɬÍפ¬¤¢¤ë¡£
160 .\"O argument specifies the permissions to be placed on the new queue,
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.
167 °ú¤¿ô¤Ï¡¢¿·¤·¤¤¥¥å¡¼¤ËŬÍѤµ¤ì¤ëµö²ÄÀßÄê (permission) ¤ò¡¢
170 (µö²Ä¥Ó¥Ã¥È¤Î¥·¥ó¥Ü¥ëÄêµÁ¤Ï
172 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë)¡£
173 µö²ÄÀßÄê¤Ï¥×¥í¥»¥¹¤Î umask ¤Ç¥Þ¥¹¥¯¤µ¤ì¤ë¡£
176 .\"O argument specifies attributes for the queue.
178 .\"O .BR mq_getattr (3)
182 .\"O is NULL, then the queue is created with implementation-defined
183 .\"O default attributes.
185 °ú¤¿ô¤Ï¡¢¥¥å¡¼¤Î°À¤ò»ØÄꤹ¤ë¡£¾ÜºÙ¤Ï¡¢
189 ¤¬ NULL ¤Î¾ì¹ç¡¢¥¥å¡¼¤Ï¼ÂÁõ¤ÇÄêµÁ¤µ¤ì¤¿¥Ç¥Õ¥©¥ë¥È°À¤ÇºîÀ®¤µ¤ì¤ë¡£
190 .\"O .SH RETURN VALUE
194 .\"O returns a message queue descriptor for use by other
195 .\"O message queue functions.
198 ¤Ï¥á¥Ã¥»¡¼¥¸¥¥å¡¼µ½Ò»Ò (message queue descriptor) ¤òÊÖ¤¹¡£
199 ¥á¥Ã¥»¡¼¥¸¥¥å¡¼µ½Ò»Ò¤Ï¾¤Î¥á¥Ã¥»¡¼¥¸¥¥å¡¼´ØÏ¢¤Î´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£
203 .\"O .IR "(mqd_t)\ \-1",
206 .\"O set to indicate the error.
213 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
218 .\"O The queue exists, but the caller does not have permission to
219 .\"O open it in the specified mode.
220 ¥¥å¡¼¤Ï¸ºß¤¹¤ë¤¬¡¢¸Æ¤Ó½Ð¤·¸µ¤¬»ØÄꤵ¤ì¤¿¥â¡¼¥É¤Ç¤½¤Î¥¥å¡¼
221 ¤ò¥ª¡¼¥×¥ó¤¹¤ëµö²Ä¤ò»ý¤¿¤Ê¤¤¡£
225 .\"O contained more than one slash.
227 ¤Ë¥¹¥é¥Ã¥·¥å¤¬ 2 ¸Ä°Ê¾å´Þ¤Þ¤ì¤Æ¤¤¤¿¡£
228 .\" Note that this isn't consistent with the same case for sem_open()
235 .\"O were specified in
237 .\"O but a queue with this
245 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¤¬¡¢»ØÄꤵ¤ì¤¿Ì¾Á°
247 ¤ò»ý¤Ä¥¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¡£
251 .\"O was specified in
255 .\"O was not NULL, but
256 .\"O .I attr\->mq_maxmsg
258 .\"O .I attr\->mq_msqsize
260 .\"O Both of these fields must be greater than zero.
271 ¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤ÏξÊý¤È¤â 0 ¤è¤êÂ礤¯¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
272 .\"O In a process that is unprivileged (does not have the
273 .\"O .B CAP_SYS_RESOURCE
275 .\"O .I attr\->mq_maxmsg
276 .\"O must be less than or equal to the
279 .\"O .I attr\->mq_msgsize
280 .\"O must be less than or equal to the
283 .\"O In addition, even in a privileged process,
284 .\"O .I attr\->mq_maxmsg
285 .\"O cannot exceed the
289 .\"O .BR mq_overview (7)
290 .\"O for details of these limits.)
291 ¥×¥í¥»¥¹¤¬Æø¢¤ò»ý¤¿¤Ê¤¤
292 .RB ( CAP_SYS_RESOURCE
293 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤¿¤Ê¤¤) ¾ì¹ç¡¢
300 °Ê²¼¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
301 ¤Þ¤¿¡¢Æø¢¥×¥í¥»¥¹¤Î¾ì¹ç¤Ç¤â¡¢
305 ¾å¸Â¤òĶ¤¨¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
306 (¤³¤ì¤é¤Î¾å¸Â¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ï
311 .\"O The process already has the maximum number of files and
312 .\"O message queues open.
313 ¤½¤Î¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤È¥á¥Ã¥»¡¼¥¸¥¥å¡¼¤Î¿ô¤¬
314 ¥×¥í¥»¥¹Ëè¤Î¾å¸Â¤Ë㤷¤Æ¤¤¤ë¡£
323 .\"O The system limit on the total number of open files and message queues
324 .\"O has been reached.
325 ¥·¥¹¥Æ¥àÁ´ÂΤǥª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤È¥á¥Ã¥»¡¼¥¸¥¥å¡¼¤Î¹ç·×¿ô¤¬
326 ¥·¥¹¥Æ¥à¾å¸Â¤Ë㤷¤Æ¤¤¤ë¡£
331 .\"O flag was not specified in
333 .\"O and no queue with this
339 ¤Ë»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¤¬¡¢»ØÄꤵ¤ì¤¿Ì¾Á°
341 ¤ò»ý¤Ä¥¥å¡¼¤¬Â¸ºß¤·¤Ê¤¤¡£
345 .\"O was just "/" followed by no other characters.
347 ¤¬ "/" ¤À¤±¤Ç¡¢¤½¤Î¸å¤í¤Ë¾¤Îʸ»ú¤¬Â³¤¤¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
348 .\" Note that this isn't consistent with the same case for sem_open()
351 .\"O Insufficient memory.
355 .\"O Insufficient space for the creation of a new message queue.
356 .\"O This probably occurred because the
358 .\"O limit was encountered; see
359 .\"O .BR mq_overview (7).
360 ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¥¥å¡¼¤òºîÀ®¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¶õ´Ö¤¬¤Ê¤¤¡£
363 ¾å¸Â¤ËÄñ¿¨¤·¤¿¤¿¤áµ¯¤³¤Ã¤¿¤Î¤À¤í¤¦¡£
366 .\"O .SH CONFORMING TO
371 .\"O In kernels before 2.6.14,
372 .\"O the process umask was not applied to the permissions specified in
374 2.6.14 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ë¤Ï¡¢
377 ¤Ç»ØÄꤵ¤ì¤¿µö²ÄÀßÄê¤ËŬÍѤµ¤ì¤Ê¤«¤Ã¤¿¡£