OSDN Git Service

e7b83a61e5aa8f0fc07d29ff0e7a750a2d88fbfa
[linuxjm/LDP_man-pages.git] / draft / man2 / msgop.2
1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided 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 .\" Modified Tue Oct 22 16:40:11 1996 by Eric S. Raymond <esr@thyrsus.com>
24 .\" Modified Mon Jul 10 21:09:59 2000 by aeb
25 .\" Modified 1 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\"     Language clean-ups.
27 .\"     Enhanced and corrected information on msg_qbytes, MSGMNB and MSGMAX
28 .\"     Added note on restart behavior of msgsnd() and msgrcv()
29 .\"     Formatting clean-ups (argument and field names marked as .I
30 .\"             instead of .B)
31 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
32 .\"     Added notes on capability requirements
33 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
34 .\"     Language and formatting clean-ups
35 .\"     Added notes on /proc files
36 .\" FIXME . Add example programs to this page.
37 .\"
38 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
39 .\"         all rights reserved.
40 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
41 .\" Modified 2000-09-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Updated 2002-11-26, Kentaro Shirakata <argrath@ub32.org>
43 .\" Updated 2005-03-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2006-03-05, Akihiro MOTOKI, LDP v2.25
45 .\" Updated 2008-08-09, Akihiro MOTOKI, LDP v3.05
46 .\"
47 .\"WORD:        message                 ¥á¥Ã¥»¡¼¥¸
48 .\"WORD:        operation               Áàºî
49 .\"WORD:        queue                   ¥­¥å¡¼
50 .\"WORD:        process                 ¥×¥í¥»¥¹
51 .\"WORD:        catch                   Êá³Í(catch)
52 .\"WORD:        signal                  ¥·¥°¥Ê¥ë
53 .\"WORD:        suspend                 Ää»ß(suspend)
54 .\"WORD:        sleep                   Ää»ß(sleep)
55 .\"WORD:        block                   Ää»ß(block)
56 .\"WORD:        process-ID              ¥×¥í¥»¥¹ID
57 .\"WORD:        type                    ·¿
58 .\"WORD:        policy                  Êý¿Ë
59 .\"WORD:        super-user              ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
60 .\"WORD:        current time            ¸½ºß»þ¹ï
61 .\"WORD:        implement               ¼ÂÁõ
62 .\"
63 .TH MSGOP 2 2008-04-23 "Linux" "Linux Programmer's Manual"
64 .\"O .SH NAME
65 .SH Ì¾Á°
66 .\"O msgrcv, msgsnd \- message operations
67 msgrcv, msgsnd \- ¥á¥Ã¥»¡¼¥¸Áàºî
68 .\"O .SH SYNOPSIS
69 .SH ½ñ¼°
70 .nf
71 .B #include <sys/types.h>
72 .B #include <sys/ipc.h>
73 .B #include <sys/msg.h>
74 .sp
75 .BI "int msgsnd(int " msqid ", const void *" msgp ", size_t " msgsz \
76 ", int " msgflg );
77 .sp
78 .BI "ssize_t msgrcv(int " msqid ", void *" msgp ", size_t " msgsz \
79 ", long " msgtyp ,
80 .BI "               int " msgflg );
81 .fi
82 .\"O .SH DESCRIPTION
83 .SH ÀâÌÀ
84 .\"O The
85 .\"O .BR msgsnd ()
86 .\"O and
87 .\"O .BR msgrcv ()
88 .\"O system calls are used, respectively, to send messages to,
89 .\"O and receive messages from, a message queue.
90 .\"O The calling process must have write permission on the message queue
91 .\"O in order to send a message, and read permission to receive a message.
92 ¥·¥¹¥Æ¥à¥³¡¼¥ë
93 .BR msgsnd ()
94 ¤È
95 .BR msgrcv ()
96 ¤Ï¤½¤ì¤¾¤ì¡¢¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Ø¤Î¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®¤È¡¢
97 ¥á¥Ã¥»¡¼¥¸¤Î¼õ¿®¤Ë»ÈÍѤµ¤ì¤ë¡£¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï¡¢
98 ¥á¥Ã¥»¡¼¥¸¤òÁ÷¿®¤¹¤ë¤¿¤á¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ËÂФ¹¤ë½ñ¤­¹þ¤ßµö²Ä¤ò¡¢
99 ¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤¹¤ë¤¿¤á¤Ë¤ÏÆɤ߽Ф·µö²Ä¤ò»ý¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
100 .PP
101 .\"O The
102 .\"O .I msgp
103 .\"O argument is a pointer to caller-defined structure
104 .\"O of the following general form:
105 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï°Ê²¼¤Ë¼¨¤¹¹½Â¤ÂΤòÍÑ°Õ¤·¡¢¤³¤Î¹½Â¤ÂΤؤÎ
106 ¥Ý¥¤¥ó¥¿¤ò
107 .msgp
108 °ú¤­¿ô¤È¤·¤ÆÅϤ¹¡£
109 .in +4n
110 .nf
111
112 struct msgbuf {
113     long mtype;       /* message type, must be > 0 */
114     char mtext[1];    /* message data */
115 };
116 .fi
117 .in
118 .PP
119 .\"O The
120 .\"O .I mtext
121 .\"O field is an array (or other structure) whose size is specified by
122 .\"O .IR msgsz ,
123 .\"O a nonnegative integer value.
124 .I mtext
125 ¥Õ¥£¡¼¥ë¥É¤ÏÇÛÎó (¤Þ¤¿¤Ï¾¤Î¹½Â¤ÂÎ) ¤Ç¡¢¤½¤ÎÂ礭¤µ¤Ï
126 ÈóÉé¤ÎÀ°¿ô¤Ç¤¢¤ë
127 .I msgsz
128 ¤Ç»ØÄꤵ¤ì¤ë¡£
129 .\"O Messages of zero length (i.e., no
130 .\"O .I mtext
131 .\"O field) are permitted.
132 Ťµ 0 ¤Î¥á¥Ã¥»¡¼¥¸ (¤Ä¤Þ¤ê
133 .I mtext
134 ¥Õ¥£¡¼¥ë¥É¤¬¤Ê¤¤¥á¥Ã¥»¡¼¥¸) ¤âǧ¤á¤é¤ì¤Æ¤¤¤ë¡£
135 .\"O The
136 .\"O .I mtype
137 .\"O field must have a strictly positive integer value.
138 .\"O This value can be
139 .\"O used by the receiving process for message selection
140 .\"O (see the description of
141 .\"O .BR msgrcv ()
142 .\"O below).
143 .B mtype
144 ¥Õ¥£¡¼¥ë¥É¤Ï¸·Ì©¤ËÀµ¤ÎÀ°¿ô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
145 ¤³¤ÎÃͤϡ¢¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤¹¤ë¥×¥í¥»¥¹¤Ç¥á¥Ã¥»¡¼¥¸¤òÁªÂò¤¹¤ë¤¿¤á¤Ë
146 »ÈÍѤµ¤ì¤ë (²¼µ­¤Î
147 .BR msgrcv ()
148 ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È)¡£
149 .SS msgsnd()
150 .\"O The
151 .\"O .BR msgsnd ()
152 .\"O system call appends a copy of the message pointed to by
153 .\"O .I msgp
154 .\"O to the message queue whose identifier is specified
155 .\"O by
156 .\"O .IR msqid .
157 .BR msgsnd ()
158 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
159 .I msgp
160 °ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿¥á¥Ã¥»¡¼¥¸¤Î¥³¥Ô¡¼¤ò
161 .I msqid
162 ¤Ç»ØÄꤵ¤ì¤¿¼±Ê̻Ҥò»ý¤Ä¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ØÄɲ乤롣
163 .PP
164 .\"O If sufficient space is available in the queue,
165 .\"O .BR msgsnd ()
166 .\"O succeeds immediately.
167 ¥­¥å¡¼¤Ë½½Ê¬¤Ê¶õ¤­ÍÆÎ̤¬¤¢¤ë¾ì¹ç¡¢
168 .BR msgsnd ()
169 ¤Ïľ¤Á¤ËÀ®¸ù¤¹¤ë¡£
170 .\"O (The queue capacity is defined by the
171 .\"O .I msg_bytes
172 .\"O field in the associated data structure for the message queue.
173 .\"O During queue creation this field is initialized to
174 .\"O .B MSGMNB
175 .\"O bytes, but this limit can be modified using
176 .\"O .BR msgctl (2).)
177 (¥­¥å¡¼¤ÎÍÆÎ̤ϡ¢¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥Ç¡¼¥¿¹½Â¤ÂΤÎ
178 .I msg_bytes
179 ¥Õ¥£¡¼¥ë¥É¤ÇÄêµÁ¤µ¤ì¤ë¡£
180 ¥­¥å¡¼ºîÀ®»þ¤Ë¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï
181 .B MSGMNB
182 ¤Ë½é´ü²½¤µ¤ì¤ë¤¬¡¢¤³¤ÎÀ©¸Â¤Ï
183 .BR msgctl (2)
184 ¤ò»È¤Ã¤ÆÊѹ¹¤Ç¤­¤ë¡£)
185 .\"O If insufficient space is available in the queue, then the default
186 .\"O behavior of
187 .\"O .BR msgsnd ()
188 .\"O is to block until space becomes available.
189 ¥­¥å¡¼¤Ë½½Ê¬¤Ê¶õ¤­ÍÆÎ̤¬¤Ê¤¤¾ì¹ç¡¢
190 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï
191 .BR msgsnd ()
192 ¤Ï¶õ¤­ÍÆÎ̤¬¤Ç¤­¤ë¤Þ¤ÇÄä»ß (block) ¤¹¤ë¡£
193 .\"O If
194 .\"O .B IPC_NOWAIT
195 .\"O is specified in
196 .\"O .IR msgflg ,
197 .\"O then the call instead fails with the error
198 .\"O .BR EAGAIN .
199 .I msgflg
200 ¤Ë
201 .B IPC_NOWAIT
202 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢¥¨¥é¡¼
203 .B EAGAIN
204 ¤Ç¼ºÇÔ¤¹¤ë¡£
205
206 .\"O A blocked
207 .\"O .BR msgsnd ()
208 .\"O call may also fail if:
209 Ää»ß¤·¤Æ¤¤¤ë
210 .BR msgsnd ()
211 ¤Ï°Ê²¼¤Î¾ì¹ç¤Ë¤â¼ºÇÔ¤¹¤ë¡£
212 .IP * 2
213 .\"O the queue is removed,
214 .\"O in which case the system call fails with
215 .\"O .I errno
216 .\"O set to
217 .\"O .BR EIDRM ;
218 .\"O or
219 ¥­¥å¡¼¤¬ºï½ü¤µ¤ì¤¿¡£
220 ¤³¤Î¾ì¹ç¡¢
221 .I errno
222 ¤Ï
223 .B EIDRM
224 ¤ËÀßÄꤵ¤ì¤ë¡£
225 .IP *
226 .\"O a signal is caught, in which case the system call fails
227 .\"O with
228 .\"O .I errno
229 .\"O set to
230 .\"O .BR EINTR ; see
231 .\"O .BR signal (7).
232 ¥·¥°¥Ê¥ë¤¬Ê᪤µ¤ì¤¿¡£
233 ¤³¤Î¾ì¹ç¡¢
234 .I errno
235 ¤Ï
236 .BR EINTR
237 ¤ËÀßÄꤵ¤ì¤ë¡£
238 .BR signal (7)
239 »²¾È¡£
240 .\"O .RB ( msgsnd ()
241 .\"O is never automatically restarted after being interrupted by a
242 .\"O signal handler, regardless of the setting of the
243 .\"O .B SA_RESTART
244 .\"O flag when establishing a signal handler.)
245 .RB ( msgsnd ()
246 ¤Ï¡¢¤¿¤È¤¨¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ÎÀßÄê»þ¤Ë
247 .B SA_RESTART
248 ¤ò»ØÄꤷ¤Æ¤¤¤¿¤È¤·¤Æ¤â¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤Ã¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¸å¤Ç
249 ¼«Æ°Åª¤ËºÆ¥¹¥¿¡¼¥È¤¹¤ë¤³¤È¤Ï·è¤·¤Æ¤Ê¤¤¡£)
250 .PP
251 .\"O Upon successful completion the message queue data structure is updated
252 .\"O as follows:
253 Àµ¾ï¤Ë½ªÎ»¤·¤¿¾ì¹ç¡¢¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥Ç¡¼¥¿¹½Â¤ÂΤϰʲ¼¤Î¤è¤¦¤Ë
254 ¹¹¿·¤µ¤ì¤ë:
255 .IP
256 .\"O .I msg_lspid
257 .\"O is set to the process ID of the calling process.
258 .I msg_lspid
259 ¤Ë¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤¬ÀßÄꤵ¤ì¤ë¡£
260 .IP
261 .\"O .I msg_qnum
262 .\"O is incremented by 1.
263 .I msg_qnum
264 ¤Ï 1 Áý²Ã¤¹¤ë¡£
265 .IP
266 .\"O .I msg_stime
267 .\"O is set to the current time.
268 .I msg_stime
269 ¤Ë¤Ï¸½ºß»þ¹ï¤¬ÀßÄꤵ¤ì¤ë¡£
270 .SS msgrcv()
271 .\"O The
272 .\"O .BR msgrcv ()
273 .\"O system call removes a message from the queue specified by
274 .\"O .I msqid
275 .\"O and places it in the buffer
276 .\"O pointed to by
277 .\"O .IR msgp .
278 .BR msgrcv ()
279 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
280 .I msqid
281 ¤Ç»ØÄꤵ¤ì¤¿¥­¥å¡¼¤«¤é¥á¥Ã¥»¡¼¥¸¤òºï½ü¤·¡¢
282 .I msgp
283 ¤Ç»ØÄꤵ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë¤½¤Î¥á¥Ã¥»¡¼¥¸¤ò³ÊǼ¤¹¤ë¡£
284 .PP
285 .\"O The argument
286 .\"O .I msgsz
287 .\"O specifies the maximum size in bytes for the member
288 .\"O .I mtext
289 .\"O of the structure pointed to by the
290 .\"O .I msgp
291 .\"O argument.
292 .I msgsz
293 °ú¤­¿ô¤Ë¤Ï
294 .I msgp
295 °ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿¹½Â¤ÂΤÎ
296 .I mtext
297 ¥á¥ó¥Ð¡¼¤ÎºÇÂç¤Î¥Ð¥¤¥È¿ô¤ò»ØÄꤹ¤ë¡£
298 .\"O If the message text has length greater than
299 .\"O .IR msgsz ,
300 .\"O then the behavior depends on whether
301 .\"O .B MSG_NOERROR
302 .\"O is specified in
303 .\"O .IR msgflg .
304 .\"O If
305 .\"O .B MSG_NOERROR
306 .\"O is specified, then
307 .\"O the message text will be truncated (and the truncated part will be
308 .\"O lost); if
309 .\"O .B MSG_NOERROR
310 .\"O is not specified, then
311 .\"O the message isn't removed from the queue and
312 .\"O the system call fails returning \-1 with
313 .\"O .I errno
314 .\"O set to
315 .\"O .BR E2BIG .
316 ¥á¥Ã¥»¡¼¥¸¤Î¥Æ¥­¥¹¥È¤ÎŤµ¤¬
317 .I msgsz
318 ¤è¤êÂ礭¤¤¾ì¹ç¤ÎÆ°ºî¤Ï¡¢
319 .I msgflg
320 ¤Ë
321 .B MSG_NOERROR
322 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ç·è¤Þ¤ë¡£
323 .B MSG_NOERROR
324 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¢¥á¥Ã¥»¡¼¥¸¤Î¥Æ¥­¥¹¥È¤ÏÀÚ¤êµÍ¤á¤é¤ì¤ë
325 (ÀÚ¤ê¼Î¤Æ¤é¤ì¤¿Éôʬ¤Ï¼º¤ï¤ì¤ë)¡£
326 .B MSG_NOERROR
327 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¥á¥Ã¥»¡¼¥¸¤Ï¥­¥å¡¼¤«¤éºï½ü¤µ¤ì¤º¡¢
328 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï \-1 ¤òÊÖ¤·¤Æ¼ºÇÔ¤·¡¢
329 .I errno
330 ¤Ë
331 .B E2BIG
332 ¤¬ÀßÄꤵ¤ì¤ë¡£
333 .PP
334 .\"O The argument
335 .\"O .I msgtyp
336 .\"O specifies the type of message requested as follows:
337 .I msgtyp
338 °ú¤­¿ô¤Ë¤ÏÍ׵᤹¤ë¥á¥Ã¥»¡¼¥¸¤Î·¿¤ò»ØÄꤹ¤ë¡£
339 ·¿¤Ï°Ê²¼¤Î¤è¤¦¤Ë»ØÄꤹ¤ë:
340 .IP * 2
341 .\"O If
342 .\"O .I msgtyp
343 .\"O is 0,
344 .\"O then the first message in the queue is read.
345 .I msgtyp
346 ¤¬ 0 ¤Ê¤é¤Ð¡¢¥­¥å¡¼¤ÎºÇ½é¤Ë¤¢¤ë¥á¥Ã¥»¡¼¥¸¤¬Æɤ߹þ¤Þ¤ì¤ë¡£
347 .IP *
348 .\"O If
349 .\"O .I msgtyp
350 .\"O is greater than 0,
351 .\"O then the first message in the queue of type
352 .\"O .I msgtyp
353 .\"O is read, unless
354 .\"O .B MSG_EXCEPT
355 .\"O was specified in
356 .\"O .IR msgflg ,
357 .\"O in which case
358 .\"O the first message in the queue of type not equal to
359 .\"O .I msgtyp
360 .\"O will be read.
361 .I msgtyp
362 ¤¬ 0 ¤è¤êÂ礭¤¤¾ì¹ç¡¢
363 .I msgflg
364 ¤Ë
365 .B MSG_EXCEPT
366 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
367 .I msgtyp
368 ·¿¤Î¥­¥å¡¼¤ÎºÇ½é¤Î¥á¥Ã¥»¡¼¥¸¤¬Æɤ߹þ¤Þ¤ì¤ë¡£
369 .B MSG_EXCEPT
370 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
371 .I msgtyp
372 ·¿°Ê³°¤Î¥­¥å¡¼¤ÎºÇ½é¤Î¥á¥Ã¥»¡¼¥¸¤¬Æɤ߹þ¤Þ¤ì¤ë¡£
373 .IP *
374 .\"O If
375 .\"O .I msgtyp
376 .\"O is less than 0,
377 .\"O then the first message in the queue with the lowest type less than or
378 .\"O equal to the absolute value of
379 .\"O .I msgtyp
380 .\"O will be read.
381 .I msgtyp
382 ¤¬ 0 ¤è¤ê¾®¤µ¤±¤ì¤Ð¡¢
383 .I msgtyp
384 ¤ÎÀäÂÐÃͰʲ¼¤ÇºÇ¤â¾®¤µ¤¤·¿¤ò»ý¤Ä¥­¥å¡¼¤ÎºÇ½é¤Î¥á¥Ã¥»¡¼¥¸¤¬Æɤ߹þ¤Þ¤ì¤ë¡£
385 .PP
386 .\"O The
387 .\"O .I msgflg
388 .\"O argument is a bit mask constructed by ORing together zero or more
389 .\"O of the following flags:
390 .I msgflg
391 °ú¤­¿ô¤Ë¤Ï¡¢°Ê²¼¤Î¥Õ¥é¥°¤òǤ°Õ¤Î¿ô¤À¤± (0¸Ä¤â²Ä)¡¢¤³¤ì¤é¤Î OR ¤Ç»ØÄꤹ¤ë:
392 .TP
393 .B IPC_NOWAIT
394 .\"O Return immediately if no message of the requested type is in the queue.
395 .\"O The system call fails with
396 .\"O .I errno
397 .\"O set to
398 .\"O .BR ENOMSG .
399 ¥­¥å¡¼¤ËÍ׵ᤵ¤ì¤¿·¿¤Î¥á¥Ã¥»¡¼¥¸¤¬¤Ê¤¤¾ì¹ç¤Ë¤Ïľ¤Á¤ËÊ֤롣
400 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¼ºÇÔ¤·¡¢
401 .I errno
402 ¤Ë¤Ï
403 .B ENOMSG
404 ¤¬ÀßÄꤵ¤ì¤ë¡£
405 .TP
406 .B MSG_EXCEPT
407 .\"O Used with
408 .\"O .I msgtyp
409 .\"O greater than 0
410 .\"O to read the first message in the queue with message type that differs
411 .\"O from
412 .\"O .IR msgtyp .
413 0 ¤è¤êÂ礭¤Ê
414 .I msgtyp
415 ¤È°ì½ï¤Ë»ÈÍѤ·¤Æ¡¢
416 .I msgtyp
417 °Ê³°¤Î¥­¥å¡¼¤ÎºÇ½é¤Î¥á¥Ã¥»¡¼¥¸¤òÆɤ߹þ¤à¡£
418 .TP
419 .B MSG_NOERROR
420 .\"O To truncate the message text if longer than
421 .\"O .I msgsz
422 .\"O bytes.
423 .I msgsz
424 ¥Ð¥¤¥È¤è¤ê¤âŤ«¤Ã¤¿¾ì¹ç¤Ï¥á¥Ã¥»¡¼¥¸¤Î¥Æ¥­¥¹¥È¤òÀÚ¤êµÍ¤á¤ë¡£
425 .PP
426 .\"O If no message of the requested type is available and
427 .\"O .B IPC_NOWAIT
428 .\"O isn't specified in
429 .\"O .IR msgflg ,
430 .\"O the calling process is blocked until one of the following conditions occurs:
431 Í׵ᤵ¤ì¤¿·¿¤Î¥á¥Ã¥»¡¼¥¸¤¬Â¸ºß¤»¤º¡¢
432 .I msgflg
433 ¤Ë
434 .B IPC_NOWAIT
435 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï
436 °Ê²¼¤Î¤¤¤º¤ì¤«¤Î¾õ¶·¤Ë¤Ê¤ë¤Þ¤ÇÄä»ß (block) ¤µ¤ì¤ë:
437 .IP * 2
438 .\"O A message of the desired type is placed in the queue.
439 Í׵ᤷ¤Æ¤¤¤ë·¿¤Î¥á¥Ã¥»¡¼¥¸¤¬¥­¥å¡¼¤ØÆþ¤ì¤é¤ì¤¿¡£
440 .IP *
441 .\"O The message queue is removed from the system.
442 .\"O In this case the system call fails with
443 .\"O .I errno
444 .\"O set to
445 .\"O .BR EIDRM .
446 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬¥·¥¹¥Æ¥à¤«¤éºï½ü¤µ¤ì¤¿¡£
447 ¤³¤Î¾ì¹ç¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¼ºÇÔ¤·¡¢
448 .I errno
449 ¤Ë
450 .B EIDRM
451 ¤¬ÀßÄꤵ¤ì¤ë¡£
452 .IP *
453 .\"O The calling process catches a signal.
454 .\"O In this case the system call fails with
455 .\"O .I errno
456 .\"O set to
457 .\"O .BR EINTR .
458 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤òÊá³Í¤·¤¿¡£
459 ¤³¤Î¾ì¹ç¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¼ºÇÔ¤·¡¢
460 .I errno
461 ¤Ë
462 .B EINTR
463 ¤¬ÀßÄꤵ¤ì¤ë¡£
464 .\"O .RB ( msgrcv ()
465 .\"O is never automatically restarted after being interrupted by a
466 .\"O signal handler, regardless of the setting of the
467 .\"O .B SA_RESTART
468 .\"O flag when establishing a signal handler.)
469 .RB ( msgrcv ()
470 ¤Ï¡¢¤¿¤È¤¨¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ÎÀßÄê»þ¤Ë
471 .B SA_RESTART
472 ¤ò»ØÄꤷ¤Æ¤¤¤¿¤È¤·¤Æ¤â¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤Ã¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¸å¤Ç
473 ¼«Æ°Åª¤ËºÆ¥¹¥¿¡¼¥È¤¹¤ë¤³¤È¤Ï·è¤·¤Æ¤Ê¤¤¡£)
474 .PP
475 .\"O Upon successful completion the message queue data structure is updated
476 .\"O as follows:
477 ¼Â¹Ô¤ËÀ®¸ù¤·¤¿¾ì¹ç¡¢¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥Ç¡¼¥¿¹½Â¤ÂΤϰʲ¼¤Î¤è¤¦¤Ë
478 ¹¹¿·¤µ¤ì¤ë:
479 .IP
480 .\"O .I msg_lrpid
481 .\"O is set to the process ID of the calling process.
482 .I msg_lrpid
483 ¤Ë¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤¬ÀßÄꤵ¤ì¤ë¡£
484 .IP
485 .\"O .I msg_qnum
486 .\"O is decremented by 1.
487 .I msg_qnum
488 ¤Ï 1 ¸º»»¤µ¤ì¤ë¡£
489 .IP
490 .\"O .I msg_rtime
491 .\"O is set to the current time.
492 .I msg_rtime
493 ¤Ë¤Ï¸½ºß¤Î»þ¹ï¤¬ÀßÄꤵ¤ì¤ë¡£
494 .\"O .SH "RETURN VALUE"
495 .SH ÊÖ¤êÃÍ
496 .\"O On failure both functions return \-1
497 .\"O with
498 .\"O .I errno
499 .\"O indicating the error,
500 .\"O otherwise
501 .\"O .BR msgsnd ()
502 .\"O returns 0
503 .\"O and
504 .\"O .BR msgrcv ()
505 .\"O returns the number of bytes actually copied into the
506 .\"O .I mtext
507 .\"O array.
508 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¡¢¤É¤Á¤é¤Î´Ø¿ô¤â \-1 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤ò
509 .I errno
510 ¤Ëɽ¼¨¤¹¤ë¡£À®¸ù¤·¤¿¾ì¹ç¡¢
511 .BR msgsnd ()
512 ¤Ï 0 ¤òÊÖ¤·¡¢
513 .BR msgrcv ()
514 ¤Ï
515 .I mtext
516 ÇÛÎó¤Ë¼ÂºÝ¤Ë¥³¥Ô¡¼¤·¤¿¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
517 .\"O .SH ERRORS
518 .SH ¥¨¥é¡¼
519 .\"O When
520 .\"O .BR msgsnd ()
521 .\"O fails,
522 .\"O .I errno
523 .\"O will be set to one among the following values:
524 .BR msgsnd ()
525 ¤¬¼ºÇÔ¤·¤¿¾ì¹ç¡¢
526 .B errno
527 ¤Ë°Ê²¼¤ÎÃͤΤ¤¤º¤ì¤«¤¬ÀßÄꤵ¤ì¤ë:
528 .TP
529 .B EACCES
530 .\"O The calling process does not have write permission on the message queue,
531 .\"O and does not have the
532 .\"O .B CAP_IPC_OWNER
533 .\"O capability.
534 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ËÂФ¹¤ë½ñ¤­¹þ¤ßµö²Ä¤¬¤Ê¤¯¡¢
535 .B CAP_IPC_OWNER
536 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤â¤Ê¤¤¡£
537 .TP
538 .B EAGAIN
539 .\"O The message can't be sent due to the
540 .\"O .I msg_qbytes
541 .\"O limit for the queue and
542 .\"O .B IPC_NOWAIT
543 .\"O was specified in
544 .\"O .IR msgflg .
545 .I msg_qbytes
546 ¤¬¥­¥å¡¼¤ÎÀ©¸Â¤òĶ¤¨¤Æ¤¤¤¿¤¿¤á¡¢¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¤³¤È¤¬¤Ç¤­¤º¡¢¤«¤Ä
547 .I msgflg
548 ¤Ë
549 .B IPC_NOWAIT
550 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¡£
551 .TP
552 .B EFAULT
553 .\"O The address pointed to by
554 .\"O .I msgp
555 .\"O isn't accessible.
556 .I msgp
557 ¤¬»Ø¤·¤Æ¤¤¤ë¥¢¥É¥ì¥¹¤¬¥¢¥¯¥»¥¹²Äǽ¤Ç¤Ê¤¤¡£
558 .TP
559 .B EIDRM
560 .\"O The message queue was removed.
561 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬ºï½ü¤µ¤ì¤¿¡£
562 .TP
563 .B EINTR
564 .\"O Sleeping on a full message queue condition, the process caught a signal.
565 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬Í׵ᤷ¤¿¾ò·ï¤òËþ¤¿¤¹¤Þ¤ÇÄä»ß¤·¤Æ¤¤¤ë»þ¤Ë¡¢
566 ¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤òÊá³Í¤·¤¿¡£
567 .TP
568 .B EINVAL
569 .\"O Invalid
570 .\"O .I msqid
571 .\"O value, or nonpositive
572 .\"O .I mtype
573 .\"O value, or
574 .\"O invalid
575 .\"O .I msgsz
576 .\"O value (less than 0 or greater than the system value
577 .\"O .BR MSGMAX ).
578 .I msqid
579 ¤¬ÉÔŬÀÚ¤ÊÃͤǤ¢¤ë¤«¡¢
580 .I mtype
581 ¤¬Àµ¤ÎÃͤǤʤ¤¤«¡¢
582 .I msgsz
583 ¤¬ÉÔŬÀÚ¤ÊÃÍ (0 °Ê²¼¤«¡¢¥·¥¹¥Æ¥à¤Ç·è¤Þ¤ëÃÍ
584 .B MSGMAX
585 ¤è¤ê¤âÂ礭¤¤ÃÍ) ¤Ç¤¢¤ë¡£
586 .TP
587 .B ENOMEM
588 .\"O The system does not have enough memory to make a copy of the
589 .\"O message pointed to by
590 .\"O .IR msgp .
591 .I msgp
592 ¤¬»Ø¤¹¥á¥Ã¥»¡¼¥¸¤Î¥³¥Ô¡¼¤òºîÀ®¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¥·¥¹¥Æ¥à¤Ë¸ºß¤·¤Ê¤¤¡£
593 .PP
594 .\"O When
595 .\"O .BR msgrcv ()
596 .\"O fails,
597 .\"O .I errno
598 .\"O will be set to one among the following values:
599 .BR msgrcv ()
600 ¤¬¼ºÇÔ¤·¤¿¾ì¹ç¤Ë¤Ï
601 .I errno
602 ¤Ë°Ê²¼¤ÎÃͤΤ¤¤º¤ì¤«¤¬ÀßÄꤵ¤ì¤ë:
603 .TP
604 .B E2BIG
605 .\"O The message text length is greater than
606 .\"O .I msgsz
607 .\"O and
608 .\"O .B MSG_NOERROR
609 .\"O isn't specified in
610 .\"O .IR msgflg .
611 ¥á¥Ã¥»¡¼¥¸¤Î¥Æ¥­¥¹¥È¤ÎŤµ¤¬
612 .I msgsz
613 ¤è¤ê¤âÂ礭¤¯¡¢
614 .I msgflg
615 ¤Ë
616 .B MSG_NOERROR
617 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
618 .TP
619 .B EACCES
620 .\"O The calling process does not have read permission on the message queue,
621 .\"O and does not have the
622 .\"O .B CAP_IPC_OWNER
623 .\"O capability.
624 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ËÂФ¹¤ëÆɤ߹þ¤ßµö²Ä¤¬¤Ê¤¯¡¢
625 .B CAP_IPC_OWNER
626 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤â¤Ê¤¤¡£
627 .TP
628 .B EAGAIN
629 .\"O No message was available in the queue and
630 .\"O .B IPC_NOWAIT
631 .\"O was specified in
632 .\"O .IR msgflg .
633 ¥­¥å¡¼¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬¤Ê¤¯¡¢
634 .I msgflg
635 ¤Ë
636 .B IPC_NOWAIT
637 ¤¬»ØÄꤵ¤ì¤¿¡£
638 .TP
639 .B EFAULT
640 .\"O The address pointed to by
641 .\"O .I msgp
642 .\"O isn't accessible.
643 .I msgp
644 ¤¬»Ø¤·¤Æ¤¤¤ë¥¢¥É¥ì¥¹¤¬¥¢¥¯¥»¥¹²Äǽ¤Ç¤Ê¤¤¡£
645 .TP
646 .B EIDRM
647 .\"O While the process was sleeping to receive a message,
648 .\"O the message queue was removed.
649 ¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤¹¤ë¤¿¤á¤Ë¥×¥í¥»¥¹¤¬Ää»ß¤·¤Æ¤¤¤ë´Ö¤Ë¡¢
650 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤¬ºï½ü¤µ¤ì¤¿¡£
651 .TP
652 .B EINTR
653 .\"O While the process was sleeping to receive a message,
654 .\"O the process caught a signal; see
655 .\"O .BR signal (7).
656 ¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¤ë¤¿¤á¤Ë¥×¥í¥»¥¹¤¬Ää»ß¤·¤Æ¤¤¤ë´Ö¤Ë¡¢
657 ¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤òÊá³Í¤·¤¿¡£
658 .BR signal (7)
659 »²¾È¡£
660 .TP
661 .B EINVAL
662 .\"O .I msgqid
663 .\"O was invalid, or
664 .\"O .I msgsz
665 .\"O was less than 0.
666 .I msgqid
667 ¤¬ÉÔÀµ¤«¡¢
668 .I msgsz
669 ¤¬ 0 ¤è¤ê¾®¤µ¤¤¡£
670 .TP
671 .B ENOMSG
672 .\"O .B IPC_NOWAIT
673 .\"O was specified in
674 .\"O .I msgflg
675 .\"O and no message of the requested type existed on the message queue.
676 .I msgflg
677 ¤Ë
678 .B IPC_NOWAIT
679 ¤¬ÀßÄꤵ¤ì¤Æ¤ª¤ê¡¢
680 ¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤ËÍ׵ᤵ¤ì¤¿·¿¤Î¥á¥Ã¥»¡¼¥¸¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¡£
681 .\"O .SH "CONFORMING TO"
682 .SH ½àµò
683 SVr4, POSIX.1-2001.
684 .\"O .SH NOTES
685 .SH Ãí°Õ
686 .\"O The
687 .\"O .I msgp
688 .\"O argument is declared as \fIstruct msgbuf *\fP with
689 .\"O libc4, libc5, glibc 2.0, glibc 2.1.
690 .\"O It is declared as \fIvoid *\fP
691 .\"O with glibc 2.2 and later, as required by SUSv2 and SUSv3.
692 .I msgp
693 °ú¤­¿ô¤Ï¡¢ libc4, libc5, glibc 2.0, glibc 2.1 ¤Ç¤Ï
694 \fIstruct msgbuf *\fP ¤ÈÀë¸À¤µ¤ì¤Æ¤¤¤ë¡£glibc 2.2 °Ê¹ß¤Ç¤Ï¡¢
695 SUSv2 ¤È SUSv3 ¤ÎÍ×µáÄ̤ꡢ\fIvoid *\fP ¤ÈÀë¸À¤µ¤ì¤Æ¤¤¤ë¡£
696
697 .\"O The following limits on message queue resources affect the
698 .\"O .BR msgsnd ()
699 .\"O call:
700 °Ê²¼¤Ï
701 .B msgsnd
702 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ë±Æ¶Á¤¹¤ë¥·¥¹¥Æ¥àÀ©¸Â¤Ç¤¢¤ë:
703 .TP
704 .B MSGMAX
705 .\"O Maximum size for a message text: 8192 bytes
706 .\"O (on Linux, this limit can be read and modified via
707 .\"O .IR /proc/sys/kernel/msgmax ).
708 ¥á¥Ã¥»¡¼¥¸¤Î¥Æ¥­¥¹¥È¤ÎºÇÂ祵¥¤¥º: 8192 ¥Ð¥¤¥È
709 (Linux ¤Ç¤Ï¡¢¤³¤ÎÀ©¸ÂÃͤÏ
710 .I /proc/sys/kernel/msgmax
711 ·Ðͳ¤ÇÆɤ߽Ф·¤¿¤êÊѹ¹¤·¤¿¤ê¤Ç¤­¤ë)¡£
712 .TP
713 .B MSGMNB
714 .\"O Default maximum size in bytes of a message queue: 16384 bytes
715 .\"O (on Linux, this limit can be read and modified via
716 .\"O .IR /proc/sys/kernel/msgmnb ).
717 .\"O The superuser can increase the size of a message queue beyond
718 .\"O .B MSGMNB
719 .\"O by a
720 .\"O .BR msgctl (2)
721 .\"O system call.
722 ¥Ð¥¤¥Èñ°Ì¤Ç¤Î¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥Ç¥Õ¥©¥ë¥È¤ÎºÇÂ祵¥¤¥º : 16384 ¥Ð¥¤¥È¡£
723 (Linux ¤Ç¤Ï¡¢¤³¤ÎÀ©¸ÂÃͤÏ
724 .I /proc/sys/kernel/msgmnb
725 ·Ðͳ¤ÇÆɤ߽Ф·¤¿¤êÊѹ¹¤·¤¿¤ê¤Ç¤­¤ë)¡£
726 ¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¡¼¤Ï
727 .BR msgctl (2)
728 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¥á¥Ã¥»¡¼¥¸¡¦¥­¥å¡¼¤Î¥µ¥¤¥º¤ò
729 .B MSGMNB
730 ¤è¤ê¤âÂ礭¤¤ÃͤËÁý¤ä¤¹¤³¤È¤¬¤Ç¤­¤ë¡£
731 .PP
732 .\"O The implementation has no intrinsic limits for the system wide maximum
733 .\"O number of message headers
734 .\"O .RB ( MSGTQL )
735 .\"O and for the system wide maximum size in bytes of the message pool
736 .\"O .RB ( MSGPOOL ).
737 ¸½ºß¤Î¼ÂÁõ¤Ç¤Ï¡¢¥·¥¹¥Æ¥àÁ´ÂΤΥá¥Ã¥»¡¼¥¸¡¦¥Ø¥Ã¥À¡¼¤ÎºÇÂç¿ô
738 .RB ( MSGTQL )
739 ¤È¡¢¥·¥¹¥Æ¥àÁ´ÂΤΥá¥Ã¥»¡¼¥¸¡¦¥×¡¼¥ë¤ÎºÇÂç¥Ð¥¤¥È¿ô
740 .RB ( MSGPOOL )
741 ¤Ë´Ø¤·¤Æ¼ÂÁõ°Í¸¤ÎÀ©¸Â¤Ï¤Ê¤¤¡£
742 .\"O .SH "SEE ALSO"
743 .SH ´ØÏ¢¹àÌÜ
744 .BR msgctl (2),
745 .BR msgget (2),
746 .BR capabilities (7),
747 .BR mq_overview (7),
748 .BR svipc (7)