OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / msgget.2
1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
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
32 .\"
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
38 .\"
39 .\"WORD:        message                 ¥á¥Ã¥»¡¼¥¸
40 .\"WORD:        queue                   ¥­¥å¡¼
41 .\"WORD:        identifier              ¼±ÊÌ»Ò
42 .\"WORD:        argument                °ú¤­¿ô
43 .\"WORD:        owner                   ½êÍ­¼Ô
44 .\"WORD:        group                   ¥°¥ë¡¼¥×
45 .\"WORD:        other                   Â¾¿Í
46 .\"WORD:        initialize              ½é´ü²½
47 .\"WORD:        effective user ID       ¼Â¸ú¥æ¡¼¥¶¡¼ID
48 .\"WORD:        effective group ID      ¼Â¸ú¥°¥ë¡¼¥×ID
49 .\"WORD:        current time            ¸½ºß»þ¹ï
50 .\"WORD:        destruction             ÇË´þ
51 .\"WORD:        policy                  Êý¿Ë
52 .\"
53 .TH MSGGET 2 2004-05-27 "Linux" "Linux Programmer's Manual"
54 .\"O .SH NAME
55 .\"O msgget \- get a message queue identifier
56 .SH Ì¾Á°
57 msgget \- ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¼±Ê̻Ҥò¼èÆÀ¤¹¤ë
58 .\"O .SH SYNOPSIS
59 .SH ½ñ¼°
60 .nf
61 .B #include <sys/types.h>
62 .B #include <sys/ipc.h>
63 .B #include <sys/msg.h>
64
65 .BI "int msgget(key_t " key ", int " msgflg );
66 .fi
67 .\"O .SH DESCRIPTION
68 .SH ÀâÌÀ
69 .\"O The
70 .\"O .BR msgget ()
71 .\"O system call returns the message queue identifier associated
72 .\"O with the value of the
73 .\"O .I key
74 .\"O argument.
75 .BR msgget ()
76 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
77 .I key
78 °ú¤­¿ô¤ÎÃͤËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¼±Ê̻ҤòÊÖ¤¹¡£
79 .\"O A new message queue is created if
80 .\"O .I key
81 .\"O has the value
82 .\"O .B IPC_PRIVATE
83 .\"O or
84 .\"O .I key
85 .\"O isn't
86 .\"O .BR IPC_PRIVATE ,
87 .\"O no message queue with the given key
88 .\"O .I key
89 .\"O exists, and
90 .\"O .B IPC_CREAT
91 .\"O is specified in
92 .\"O .IR msgflg .
93 .I key
94 ¤ÎÃͤ¬
95 .B IPC_PRIVATE
96 ¤Î¾ì¹ç¡¢¤Þ¤¿¤Ï
97 .I key
98 ¤¬
99 .B IPC_PRIVATE
100 ¤Ç¤Ê¤¯¤Æ¤â¡¢
101 .I key
102 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬Â¸ºß¤»¤º¡¢
103 .I msgflg
104 ¤Ë
105 .B IPC_CREAT
106 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
107 ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬ºîÀ®¤µ¤ì¤ë¡£
108 .PP
109 .\"O If
110 .\"O .I msgflg
111 .\"O specifies both
112 .\"O .B IPC_CREAT
113 .\"O and
114 .\"O .B IPC_EXCL
115 .\"O and a message queue already exists for
116 .\"O .IR key ,
117 .\"O then
118 .\"O .BR msgget ()
119 .\"O fails with
120 .\"O .I errno
121 .\"O set to
122 .\"O .BR EEXIST .
123 .\"O (This is analogous to the effect of the combination
124 .\"O .B O_CREAT | O_EXCL
125 .\"O for
126 .\"O .BR open (2).)
127 .I msgflg
128 ¤Ë
129 .B IPC_CREAT
130 ¤È
131 .B IPC_EXCL
132 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
133 .I key
134 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬´û¤Ë¸ºß¤¹¤ë¤È¡¢
135 .BR msgget ()
136 ¤Ï¼ºÇÔ¤·¡¢
137 .I errno
138 ¤Ë
139 .B EEXIST
140 ¤¬ÀßÄꤵ¤ì¤ë¡£
141 (¤³¤ì¤Ï
142 .BR open (2)
143 ¤Ë
144 .B O_CREAT | O_EXCL
145 ¤ò»ØÄꤷ¤¿¾ì¹ç¤ÎÆ°ºî¤ÈƱ¤¸¤Ç¤¢¤ë)
146 .PP
147 .\"O Upon creation, the least significant bits of the argument
148 .\"O .I msgflg
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
152 .\"O .I mode
153 .\"O argument of
154 .\"O .BR open (2).
155 .\"O (The execute permissions are not used.)
156 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ÎºîÀ®»þ¤Ë¡¢
157 .I msgflg
158 °ú¤­¿ô¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤Ï¡¢
159 ¤½¤Î¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥¢¥¯¥»¥¹µö²Ä¤ÎÄêµÁ¤È¤·¤Æ»ÈÍѤµ¤ì¤ë¡£
160 ¤³¤ì¤é¤Îµö²Ä¥Ó¥Ã¥È¤Ï
161 .BR open (2)
162 ¤Î°ú¤­¿ô
163 .I mode
164 ¤ÈƱ¤¸·Á¼°¤ÇƱ¤¸°ÕÌ£¤Ç¤¢¤ë¡£
165 ¤ä
166 .BR creat (2)
167 ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Î¥¢¥¯¥»¥¹µö²Ä¥Ñ¥é¥á¡¼¥¿¤ÈƱ¤¸·Á¼°¤Ç¡¢Æ±¤¸°ÕÌ£¤ò»ý¤Ä¡£
168 (⤷¡¢¼Â¹Ô (execute) µö²Ä¤Ï»ÈÍѤµ¤ì¤Ê¤¤¡£)
169 .PP
170 .\"O If a new message queue is created,
171 .\"O then its associated data structure
172 .\"O .I msqid_ds
173 .\"O (see
174 .\"O .BR msgctl (2))
175 .\"O is initialized as follows:
176 ¿·µ¬¤Î¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤òºîÀ®¤¹¤ëºÝ¡¢
177 .BR msgget ()
178 ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤Ï¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥Ç¡¼¥¿¹½Â¤ÂÎ
179 .I msqid_ds
180 ¤ò°Ê²¼¤Î¤è¤¦¤Ë½é´ü²½¤¹¤ë
181 .RI ( msqid_ds
182 ¤Ë¤Ä¤¤¤Æ¤Ï
183 .BR msgctl (2)
184 ¤ò»²¾È):
185 .IP
186 .\"O .I msg_perm.cuid
187 .\"O and
188 .\"O .I msg_perm.uid
189 .\"O are set to the effective user ID of the calling process.
190 .I msg_perm.cuid
191 ¤È
192 .I msg_perm.uid
193 ¤Ë¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥æ¡¼¥¶¡¼ID ¤òÀßÄꤹ¤ë¡£
194 .IP
195 .\"O .I msg_perm.cgid
196 .\"O and
197 .\"O .I msg_perm.gid
198 .\"O are set to the effective group ID of the calling process.
199 .I msg_perm.cgid
200 ¤È
201 .I msg_perm.gid
202 ¤Ë¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥°¥ë¡¼¥×ID ¤òÀßÄꤹ¤ë¡£
203 .IP
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
207 .\"O .IR msgflg .
208 .I msg_perm.mode
209 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤Ï
210 .I msgflg
211 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤òÀßÄꤹ¤ë¡£
212 .IP
213 .\"O .IR msg_qnum ,
214 .\"O .IR msg_lspid ,
215 .\"O .IR msg_lrpid ,
216 .\"O .I msg_stime
217 .\"O and
218 .\"O .I msg_rtime
219 .\"O are set to 0.
220 .IR msg_qnum ,
221 .IR msg_lspid ,
222 .IR msg_lrpid ,
223 .IR msg_stime ,
224 .I msg_rtime
225 ¤Ë 0 ¤òÀßÄꤵ¤ì¤ë¡£
226 .IP
227 .\"O .I msg_ctime
228 .\"O is set to the current time.
229 .I msg_ctime
230 ¤Ë¸½ºß¤Î»þ¹ï¤òÀßÄꤹ¤ë¡£
231 .IP
232 .\"O .I msg_qbytes
233 .\"O is set to the system limit
234 .\"O .BR MSGMNB .
235 .I msg_qbytes
236 ¤Ë¡¢¥·¥¹¥Æ¥à¤Ç·è¤á¤é¤ì¤¿¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ÎºÇÂ祵¥¤¥º
237 .B MSGMNB
238 ¤òÀßÄꤹ¤ë¡£
239 .PP
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
242 .\"O destruction.
243 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬¤¹¤Ç¤Ë¸ºß¤¹¤ë¾ì¹ç¤Ï¡¢¥¢¥¯¥»¥¹µö²Ä¤Î¸¡ºº¤È¡¢
244 ÇË´þ (destruction) ¥Þ¡¼¥¯¤¬¤Ê¤¤¤«¤Î³Îǧ¤¬¹Ô¤ï¤ì¤ë¡£
245 .\"O .SH "RETURN VALUE"
246 .SH ÊÖ¤êÃÍ
247 .\"O If successful, the return value will be the message queue identifier (a
248 .\"O nonnegative integer), otherwise \-1
249 .\"O with
250 .\"O .I errno
251 .\"O indicating the error.
252 À®¸ù¤·¤¿¾ì¹ç¡¢ÊÖ¤êÃͤϥá¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¼±Ê̻Ҡ(ÈóÉé¤ÎÀ°¿ô) ¤È¤Ê¤ë¡£
253 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
254 .I errno
255 ¤Ë¤½¤Î¥¨¥é¡¼¤¬¼¨¤µ¤ì¤ë¡£
256 .\"O .SH ERRORS
257 .SH ¥¨¥é¡¼
258 .\"O On failure,
259 .\"O .I errno
260 .\"O is set to one of the following values:
261 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢
262 .I errno
263 ¤Ë°Ê²¼¤ÎÃͤΤ¤¤º¤ì¤«°ì¤Ä¤¬ÀßÄꤵ¤ì¤ë:
264 .TP
265 .B EACCES
266 .\"O A message queue exists for
267 .\"O .IR key ,
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
271 .\"O capability.
272 .I key
273 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Ï¸ºß¤¹¤ë¤¬¡¢
274 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï¤½¤Î¥­¥å¡¼¤ËÂФ¹¤ë¥¢¥¯¥»¥¹µö²Ä¤¬¤Ê¤¯¡¢
275 .B CAP_IPC_OWNER
276 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤â»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
277 .TP
278 .B EEXIST
279 .\"O A message queue exists for
280 .\"O .I key
281 .\"O and
282 .\"O .I msgflg
283 .\"O specified both
284 .\"O .B IPC_CREAT
285 .\"O and
286 .\"O .BR IPC_EXCL .
287 .I key
288 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬Â¸ºß¤·¡¢
289 .I msgflg
290 ¤Ë
291 .B IPC_CREAT
292 ¤È
293 .B IPC_EXCL
294 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¡£
295 .TP
296 .B ENOENT
297 .\"O No message queue exists for
298 .\"O .I key
299 .\"O and
300 .\"O .I msgflg
301 .\"O did not specify
302 .\"O .BR IPC_CREAT .
303 .I key
304 ¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬Â¸ºß¤»¤º¡¢
305 .I msgflg
306 ¤Ë
307 .B IPC_CREAT
308 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
309 .TP
310 .B ENOMEM
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 ¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¥·¥¹¥Æ¥à¤Ë¸ºß¤·¤Ê¤¤¡£
315 .TP
316 .B ENOSPC
317 .\"O A message queue has to be created but the system limit for the maximum
318 .\"O number of message queues
319 .\"O .RB ( MSGMNI )
320 .\"O would be exceeded.
321 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤òºîÀ®¤·¤è¤¦¤È¤·¤¿¤¬¡¢ºîÀ®¤¹¤ë¤È
322 ¥·¥¹¥Æ¥àÁ´ÂΤΥá¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¿ô¤ÎºÇÂçÃÍ
323 .RB ( MSGMNI )
324 ¤òĶ¤¨¤Æ¤·¤Þ¤¦¡£
325 .\"O .SH "CONFORMING TO"
326 .SH ½àµò
327 SVr4, POSIX.1-2001.
328 .\"O .SH NOTES
329 .SH Ãí°Õ
330 .\"O .B IPC_PRIVATE
331 .\"O isn't a flag field but a
332 .\"O .I key_t
333 .\"O type.
334 .B IPC_PRIVATE
335 ¤Ï¥Õ¥é¥°¤Ç¤Ï¤Ê¤¯¡¢
336 .I key_t
337 ·¿¤Ç¤¢¤ë¡£
338 .\"O If this special value is used for
339 .\"O .IR key ,
340 .\"O the system call ignores everything but the least significant 9 bits of
341 .\"O .I msgflg
342 .\"O and creates a new message queue (on success).
343 ¤³¤ÎÆÃÊ̤ÊÃͤ¬
344 .I key
345 ¤È¤·¤Æ»ÈÍѤµ¤ì¤¿¾ì¹ç¡¢
346 .BR msgget ()
347 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
348 .I msgflg
349 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È°Ê³°¤ÎÁ´¤Æ¤ò̵»ë¤·¤Æ
350 (À®¸ù¤·¤¿¾ì¹ç¤Ï) ¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤òºîÀ®¤¹¤ë¡£
351 .PP
352 .\"O The following is a system limit on message queue resources affecting a
353 .\"O .BR msgget ()
354 .\"O call:
355 .BR msgget ()
356 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î»ñ¸»¤Î
357 ¥·¥¹¥Æ¥à¤È¤·¤Æ¤ÎÀ©¸Â¤ò°Ê²¼¤Ë¼¨¤¹:
358 .TP
359 .B MSGMNI
360 .\"O System wide maximum number of message queues: policy
361 .\"O dependent
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"
369 .SS Linux ¤Ç¤ÎÃí°Õ
370 .\"O Until version 2.3.20 Linux would return
371 .\"O .B EIDRM
372 .\"O for a
373 .\"O .BR msgget ()
374 .\"O on a message queue scheduled for deletion.
375 Linux 2.3.20 ¤Þ¤Ç¤Ï¡¢ºï½ü¤¬Í½Äꤵ¤ì¤Æ¤¤¤ë¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ËÂФ·¤Æ
376 .BR msgget ()
377 ¤ò¹Ô¤¦¤È
378 .B EIDRM
379 ¤¬¥¨¥é¡¼¤È¤·¤ÆÊÖ¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤¿¡£
380 .\"O .SH BUGS
381 .SH ¥Ð¥°
382 .\"O The name choice
383 .\"O .B IPC_PRIVATE
384 .\"O was perhaps unfortunate,
385 .\"O .B IPC_NEW
386 .\"O would more clearly show its function.
387 .B IPC_PRIVATE
388 ¤È¤¤¤¦Ì¾Á°¤òÁª¤ó¤À¤Î¤Ï¤ª¤½¤é¤¯¼ºÇԤǤ¢¤í¤¦¡£
389 .B IPC_NEW
390 ¤ÎÊý¤¬¤è¤êÌÀ³Î¤Ë¤½¤Îµ¡Ç½¤òɽ¤·¤Æ¤¤¤ë¤À¤í¤¦¡£
391 .\"O .SH "SEE ALSO"
392 .SH ´ØÏ¢¹àÌÜ
393 .BR msgctl (2),
394 .BR msgrcv (2),
395 .BR msgsnd (2),
396 .BR ftok (3),
397 .BR capabilities (7),
398 .BR mq_overview (7),
399 .BR svipc (7)