1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provflags the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Added correction due to Nick Duffek <nsd@bbc.com>, aeb, 960426
24 .\" Modified Wed Nov 6 04:00:31 1996 by Eric S. Raymond <esr@thyrsus.com>
25 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
26 .\" Removed EIDRM from errors - that can't happen...
27 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
28 .\" Added notes on capability requirements
29 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" Language and formatting clean-ups
31 .\" Added notes on /proc files
33 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
34 .\" all rights reserved.
35 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
36 .\" Modified 2003-07-03, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
37 .\" Updated 2005-03-04, Akihiro MOTOKI
39 .\"WORD: message ¥á¥Ã¥»¡¼¥¸
41 .\"WORD: identifier ¼±ÊÌ»Ò
42 .\"WORD: argument °ú¤¿ô
44 .\"WORD: group ¥°¥ë¡¼¥×
46 .\"WORD: initialize ½é´ü²½
47 .\"WORD: effective user ID ¼Â¸ú¥æ¡¼¥¶¡¼ID
48 .\"WORD: effective group ID ¼Â¸ú¥°¥ë¡¼¥×ID
49 .\"WORD: current time ¸½ºß»þ¹ï
50 .\"WORD: destruction ÇË´þ
53 .TH MSGGET 2 2004-05-27 "Linux" "Linux Programmer's Manual"
55 .\"O msgget \- get a message queue identifier
57 msgget \- ¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¼±Ê̻Ҥò¼èÆÀ¤¹¤ë
61 .B #include <sys/types.h>
62 .B #include <sys/ipc.h>
63 .B #include <sys/msg.h>
65 .BI "int msgget(key_t " key ", int " msgflg );
71 .\"O system call returns the message queue identifier associated
72 .\"O with the value of the
78 °ú¤¿ô¤ÎÃͤËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤Î¼±Ê̻ҤòÊÖ¤¹¡£
79 .\"O A new message queue is created if
86 .\"O .BR IPC_PRIVATE ,
87 .\"O no message queue with the given key
102 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬Â¸ºß¤»¤º¡¢
106 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
107 ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬ºîÀ®¤µ¤ì¤ë¡£
115 .\"O and a message queue already exists for
123 .\"O (This is analogous to the effect of the combination
124 .\"O .B O_CREAT | O_EXCL
132 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
134 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬´û¤Ë¸ºß¤¹¤ë¤È¡¢
145 ¤ò»ØÄꤷ¤¿¾ì¹ç¤ÎÆ°ºî¤ÈƱ¤¸¤Ç¤¢¤ë)
147 .\"O Upon creation, the least significant bits of the argument
149 .\"O define the permissions of the message queue.
150 .\"O These permission bits have the same format and semantics
151 .\"O as the permissions specified for the
155 .\"O (The execute permissions are not used.)
156 ¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤ÎºîÀ®»þ¤Ë¡¢
158 °ú¤¿ô¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤Ï¡¢
159 ¤½¤Î¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤Î¥¢¥¯¥»¥¹µö²Ä¤ÎÄêµÁ¤È¤·¤Æ»ÈÍѤµ¤ì¤ë¡£
164 ¤ÈƱ¤¸·Á¼°¤ÇƱ¤¸°ÕÌ£¤Ç¤¢¤ë¡£
167 ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Î¥¢¥¯¥»¥¹µö²Ä¥Ñ¥é¥á¡¼¥¿¤ÈƱ¤¸·Á¼°¤Ç¡¢Æ±¤¸°ÕÌ£¤ò»ý¤Ä¡£
168 (⤷¡¢¼Â¹Ô (execute) µö²Ä¤Ï»ÈÍѤµ¤ì¤Ê¤¤¡£)
170 .\"O If a new message queue is created,
171 .\"O then its associated data structure
175 .\"O is initialized as follows:
176 ¿·µ¬¤Î¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤òºîÀ®¤¹¤ëºÝ¡¢
178 ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Ï¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤Î¥Ç¡¼¥¿¹½Â¤ÂÎ
180 ¤ò°Ê²¼¤Î¤è¤¦¤Ë½é´ü²½¤¹¤ë
186 .\"O .I msg_perm.cuid
189 .\"O are set to the effective user ID of the calling process.
193 ¤Ë¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥æ¡¼¥¶¡¼ID ¤òÀßÄꤹ¤ë¡£
195 .\"O .I msg_perm.cgid
198 .\"O are set to the effective group ID of the calling process.
202 ¤Ë¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥°¥ë¡¼¥×ID ¤òÀßÄꤹ¤ë¡£
204 .\"O The least significant 9 bits of
205 .\"O .I msg_perm.mode
206 .\"O are set to the least significant 9 bits of
211 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤òÀßÄꤹ¤ë¡£
228 .\"O is set to the current time.
230 ¤Ë¸½ºß¤Î»þ¹ï¤òÀßÄꤹ¤ë¡£
233 .\"O is set to the system limit
236 ¤Ë¡¢¥·¥¹¥Æ¥à¤Ç·è¤á¤é¤ì¤¿¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤ÎºÇÂ祵¥¤¥º
240 .\"O If the message queue already exists the permissions are
241 .\"O verified, and a check is made to see if it is marked for
243 ¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¾ì¹ç¤Ï¡¢¥¢¥¯¥»¥¹µö²Ä¤Î¸¡ºº¤È¡¢
244 ÇË´þ (destruction) ¥Þ¡¼¥¯¤¬¤Ê¤¤¤«¤Î³Îǧ¤¬¹Ô¤ï¤ì¤ë¡£
245 .\"O .SH "RETURN VALUE"
247 .\"O If successful, the return value will be the message queue identifier (a
248 .\"O nonnegative integer), otherwise \-1
251 .\"O indicating the error.
252 À®¸ù¤·¤¿¾ì¹ç¡¢ÊÖ¤êÃͤϥá¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¼±ÊÌ»Ò (ÈóÉé¤ÎÀ°¿ô) ¤È¤Ê¤ë¡£
253 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
255 ¤Ë¤½¤Î¥¨¥é¡¼¤¬¼¨¤µ¤ì¤ë¡£
260 .\"O is set to one of the following values:
263 ¤Ë°Ê²¼¤ÎÃͤΤ¤¤º¤ì¤«°ì¤Ä¤¬ÀßÄꤵ¤ì¤ë:
266 .\"O A message queue exists for
268 .\"O but the calling process does not have permission to access the queue,
269 .\"O and does not have the
270 .\"O .B CAP_IPC_OWNER
273 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤Ï¸ºß¤¹¤ë¤¬¡¢
274 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï¤½¤Î¥¥å¡¼¤ËÂФ¹¤ë¥¢¥¯¥»¥¹µö²Ä¤¬¤Ê¤¯¡¢
276 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤â»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
279 .\"O A message queue exists for
288 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬Â¸ºß¤·¡¢
297 .\"O No message queue exists for
304 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤¬Â¸ºß¤»¤º¡¢
308 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
311 .\"O A message queue has to be created but the system does not have enough
312 .\"O memory for the new data structure.
313 ¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤òºîÀ®¤·¤è¤¦¤È¤·¤¿¤¬¡¢¿·¤·¤¤¥Ç¡¼¥¿¹½Â¤ÂΤòºîÀ®
314 ¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¥·¥¹¥Æ¥à¤Ë¸ºß¤·¤Ê¤¤¡£
317 .\"O A message queue has to be created but the system limit for the maximum
318 .\"O number of message queues
320 .\"O would be exceeded.
321 ¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤òºîÀ®¤·¤è¤¦¤È¤·¤¿¤¬¡¢ºîÀ®¤¹¤ë¤È
322 ¥·¥¹¥Æ¥àÁ´ÂΤΥá¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¿ô¤ÎºÇÂçÃÍ
325 .\"O .SH "CONFORMING TO"
331 .\"O isn't a flag field but a
338 .\"O If this special value is used for
340 .\"O the system call ignores everything but the least significant 9 bits of
342 .\"O and creates a new message queue (on success).
345 ¤È¤·¤Æ»ÈÍѤµ¤ì¤¿¾ì¹ç¡¢
349 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È°Ê³°¤ÎÁ´¤Æ¤ò̵»ë¤·¤Æ
350 (À®¸ù¤·¤¿¾ì¹ç¤Ï) ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤òºîÀ®¤¹¤ë¡£
352 .\"O The following is a system limit on message queue resources affecting a
356 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤Î»ñ¸»¤Î
357 ¥·¥¹¥Æ¥à¤È¤·¤Æ¤ÎÀ©¸Â¤ò°Ê²¼¤Ë¼¨¤¹:
360 .\"O System wide maximum number of message queues: policy
362 .\"O (on Linux, this limit can be read and modified via
363 .\"O .IR /proc/sys/kernel/msgmni ).
364 ¥·¥¹¥Æ¥àÁ´ÂΤΥá¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¿ô¤ÎºÇÂçÃÍ: Êý¿Ë°Í¸
365 (Linux ¤Ç¤Ï¡¢¤³¤ÎÀ©¸ÂÃͤÏ
366 .I /proc/sys/kernel/msgmni
367 ·Ðͳ¤Ç»²¾È¤·¤¿¤ê¡¢Êѹ¹¤·¤¿¤ê¤Ç¤¤ë)¡£
368 .\"O .SS "Linux Notes"
370 .\"O Until version 2.3.20 Linux would return
374 .\"O on a message queue scheduled for deletion.
375 Linux 2.3.20 ¤Þ¤Ç¤Ï¡¢ºï½ü¤¬Í½Äꤵ¤ì¤Æ¤¤¤ë¥á¥Ã¥»¡¼¥¸¡¦¥¥å¡¼¤ËÂФ·¤Æ
379 ¤¬¥¨¥é¡¼¤È¤·¤ÆÊÖ¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤¿¡£
384 .\"O was perhaps unfortunate,
386 .\"O would more clearly show its function.
388 ¤È¤¤¤¦Ì¾Á°¤òÁª¤ó¤À¤Î¤Ï¤ª¤½¤é¤¯¼ºÇԤǤ¢¤í¤¦¡£
390 ¤ÎÊý¤¬¤è¤êÌÀ³Î¤Ë¤½¤Îµ¡Ç½¤òɽ¤·¤Æ¤¤¤ë¤À¤í¤¦¡£
397 .BR capabilities (7),