OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / mq_receive.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 .\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.13
29 .\"
30 .TH MQ_RECEIVE 3 2010-09-20 "Linux" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH Ì¾Á°
33 .\"O mq_receive, mq_timedreceive \- receive a message from a message queue
34 mq_receive, mq_timedreceive \- ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤¹¤ë
35 .\"O .SH SYNOPSIS
36 .SH ½ñ¼°
37 .nf
38 .B #include <mqueue.h>
39 .sp
40 .BI "ssize_t mq_receive(mqd_t " mqdes ", char *" msg_ptr ,
41 .BI "                   size_t " msg_len ", unsigned *" msg_prio );
42 .sp
43 .B #include <time.h>
44 .B #include <mqueue.h>
45 .sp
46 .BI "ssize_t mq_timedreceive(mqd_t " mqdes ", char *" msg_ptr ,
47 .BI "                   size_t " msg_len ", unsigned *" msg_prio ,
48 .BI "                   const struct timespec *" abs_timeout );
49 .fi
50 .sp
51 .\"O Link with \fI\-lrt\fP.
52 \fI\-lrt\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
53 .sp
54 .ad l
55 .in -4n
56 .\"O Feature Test Macro Requirements for glibc (see
57 .\"O .BR feature_test_macros (7)):
58 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
59 .RB ( feature_test_macros (7)
60 »²¾È):
61 .in
62 .sp
63 .BR mq_timedreceive ():
64 .RS 4
65 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
66 .RE
67 .ad
68 .\"O .SH DESCRIPTION
69 .SH ÀâÌÀ
70 .\"O .BR mq_receive ()
71 .\"O removes the oldest message with the highest priority from
72 .\"O the message queue referred to by the descriptor
73 .\"O .IR mqdes ,
74 .\"O and places it in the buffer pointed to by
75 .\"O .IR msg_ptr .
76 .BR mq_receive ()
77 ¤Ï¡¢µ­½Ò»Ò
78 .I mqdes
79 ¤Ç»²¾È¤µ¤ì¤ë¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤«¤éºÇ¤â¹â¤¤Í¥ÀèÅÙ¤ò»ý¤Ä
80 ºÇ¤â¸Å¤¤¥á¥Ã¥»¡¼¥¸¤òºï½ü¤·¡¢¤½¤Î¥á¥Ã¥»¡¼¥¸¤ò
81 .I msg_ptr
82 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£
83 .\"O The
84 .\"O .I msg_len
85 .\"O argument specifies the size of the buffer pointed to by
86 .\"O .IR msg_ptr ;
87 .\"O this must be greater than the
88 .\"O .I mq_msgsize
89 .\"O attribute of the queue (see
90 .\"O .BR mq_getattr (3)).
91 .I msg_len
92 °ú¤­¿ô¤Ï¡¢
93 .I msg_ptr
94 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤ÎÂ礭¤µ¤ò¼¨¤¹¡£¤³¤ÎÃͤϥ­¥å¡¼¤Î
95 .I mq_msgsize
96 °À­¤è¤ê¤âÂ礭¤¯¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
97 .RB ( mq_getattr (3)
98 »²¾È)¡£
99 .\"O If
100 .\"O .I prio
101 .\"O is not NULL, then the buffer to which it points is used
102 .\"O to return the priority associated with the received message.
103 .I prio
104 ¤¬ NULL °Ê³°¤Î¾ì¹ç¡¢
105 .I prio
106 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë¼õ¿®¤·¤¿¥á¥Ã¥»¡¼¥¸¤ÎÍ¥ÀèÅÙ¤¬³ÊǼ¤µ¤ì¤ë¡£
107
108 .\"O If the queue is empty, then, by default,
109 .\"O .BR mq_receive ()
110 .\"O blocks until a message becomes available,
111 .\"O or the call is interrupted by a signal handler.
112 .\"O If the
113 .\"O .B O_NONBLOCK
114 .\"O flag is enabled for the message queue description,
115 .\"O then the call instead fails immediately with the error
116 .\"O .BR EAGAIN .
117 ¥­¥å¡¼¤¬¶õ¤Î¾ì¹ç¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢
118 .BR mq_receive ()
119 ¤Ï¡¢¿·¤·¤¤¥á¥Ã¥»¡¼¥¸¤¬ÆϤ¯¤«¡¢´Ø¿ô¸Æ¤Ó½Ð¤·¤¬¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤ê
120 ÃæÃǤµ¤ì¤ë¤Þ¤Ç¡¢Ää»ß (block) ¤¹¤ë¡£
121 ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼µ­½Ò (message queue description) ¤Ç
122 .B O_NONBLOCK
123 ¥Õ¥é¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢
124 .BR mq_receive ()
125 ¤Ï¥¨¥é¡¼
126 .B EAGAIN
127 ¤Ç¤¹¤°¤Ë¼ºÇÔ¤¹¤ë¡£
128
129 .\"O .BR mq_timedreceive ()
130 .\"O behaves just like
131 .\"O .BR mq_receive (),
132 .\"O except that if the queue is empty and the
133 .\"O .B O_NONBLOCK
134 .\"O flag is not enabled for the message queue description, then
135 .\"O .I abs_timeout
136 .\"O points to a structure which specifies a ceiling on the time for which
137 .\"O the call will block.
138 .\"O This ceiling is an absolute timeout in seconds and nanoseconds
139 .\"O since the Epoch, 1970-01-01 00:00:00 +0000 (UTC), and it is
140 .\"O specified in the following structure:
141 .BR mq_timedreceive ()
142 ¤Ï
143 .BR mq_receive ()
144 ¤ÈÁ´¤¯Æ±¤¸Æ°ºî¤ò¤¹¤ë¤¬¡¢
145 ¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤¬¶õ¤Ç¡¢¥á¥Ã¥»¡¼¥¸¥­¥å¡¼µ­½Ò¤Ç
146 .B O_NONBLOCK
147 ¥Õ¥é¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¡¢¤³¤Î¸Æ¤Ó½Ð¤·¤¬Ää»ß¤¹¤ë»þ´Ö¤Î¾å¸Â¤ò
148 .I abs_timeout
149 ¤¬»Ø¤¹¹½Â¤ÂΤǻØÄꤹ¤ëÅÀ¤¬°Û¤Ê¤ë¡£¤³¤Î¾å¸Â¤Ï¡¢¥¿¥¤¥à¥¢¥¦¥È¤Î»þ¹ï¤ò¡¢
150 »þ¹ïµª¸µ (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) ¤«¤é¤Î·Ð²á»þ´Ö
151 (ÉäȥʥÎÉäÎÁÈ) ¤Ç»ØÄꤹ¤ë¡£¥¿¥¤¥à¥¢¥¦¥È»þ¹ï¤Ï°Ê²¼¤Î¹½Â¤ÂΤǻØÄꤹ¤ë:
152 .sp
153 .in +4n
154 .nf
155 struct timespec {
156 .\"O     time_t tv_sec;        /* seconds */
157 .\"O     long   tv_nsec;       /* nanoseconds */
158     time_t tv_sec;        /* Éà*/
159     long   tv_nsec;       /* ¥Ê¥ÎÉà*/
160 };
161
162 .fi
163 .in
164 .\"O If no message is available,
165 .\"O and the timeout has already expired by the time of the call,
166 .\"O .BR mq_timedreceive ()
167 .\"O returns immediately.
168 ¥á¥Ã¥»¡¼¥¸¤¬¥­¥å¡¼¤Ë¤Ê¤¯¡¢´Ø¿ô¸Æ¤Ó½Ð¤·»þ¤Ë¤¹¤Ç¤Ë¥¿¥¤¥à¥¢¥¦¥È»þ¹ï¤¬
169 ²á¤®¤Æ¤¤¤ë¾ì¹ç¡¢
170 .BR mq_timedreceive ()
171 ¤Ï¤¹¤°¤ËÊ֤롣
172 .\"O .SH RETURN VALUE
173 .SH ÊÖ¤êÃÍ
174 .\"O On success,
175 .\"O .BR mq_receive ()
176 .\"O and
177 .\"O .BR mq_timedreceive ()
178 .\"O return the number of bytes in the received message;
179 .\"O on error, \-1 is returned, with
180 .\"O .I errno
181 .\"O set to indicate the error.
182 À®¸ù¤¹¤ë¤È¡¢
183 .BR mq_receive ()
184 ¤È
185 .BR mq_timedreceive ()
186 ¤Ï¼õ¿®¤·¤¿¥á¥Ã¥»¡¼¥¸¤Î¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
187 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
188 .I errno
189 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
190 .\"O .SH ERRORS
191 .SH ¥¨¥é¡¼
192 .TP
193 .B EAGAIN
194 .\"O The queue was empty, and the
195 .\"O .B O_NONBLOCK
196 .\"O flag was set for the message queue description referred to by
197 .\"O .IR mqdes .
198 ¥­¥å¡¼¤¬¶õ¤Ç¡¢¤«¤Ä
199 .I mqdes
200 ¤Ç»²¾È¤µ¤ì¤ë¥á¥Ã¥»¡¼¥¸¥­¥å¡¼µ­½Ò¤Ç
201 .B O_NONBLOCK
202 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤¿¡£
203 .TP
204 .B EBADF
205 .\"O The descriptor specified in
206 .\"O .I mqdes
207 .\"O was invalid.
208 .I mqdes
209 ¤Ç»ØÄꤵ¤ì¤¿µ­½Ò»Ò¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
210 .TP
211 .B EINTR
212 .\"O The call was interrupted by a signal handler; see
213 .\"O .BR signal (7).
214 ´Ø¿ô¸Æ¤Ó½Ð¤·¤¬¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤êÃæÃǤµ¤ì¤¿¡£
215 .BR signal (7)
216 »²¾È¡£
217 .TP
218 .B EINVAL
219 .\"O The call would have blocked, and
220 .\"O .I abs_timeout
221 .\"O was invalid, either because
222 .\"O .I tv_sec
223 .\"O was less than zero, or because
224 .\"O .I tv_nsec
225 .\"O was less than zero or greater than 1000 million.
226 ´Ø¿ô¸Æ¤Ó½Ð¤·¤ÏÄä»ß¤¹¤ë¤Ï¤º¤Ç¤¢¤Ã¤¿¤¬¡¢
227 .I abs_timeout
228 ¤¬ÉÔÀµ¤Ç¤¢¤Ã¤¿¡£
229 .I abs_timeout
230 ¤¬ÉÔÀµ¤È¤Ï¡¢
231 .I tv_sec
232 ¤¬ 0 Ì¤Ëþ¡¢¤â¤·¤¯¤Ï
233 .I tv_nsec
234 ¤¬ 0 Ì¤Ëþ¤« 1,000,000,000 ¤è¤êÂ礭¤¤¡¢¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡£
235 .TP
236 .B EMSGSIZE
237 .\"O .I msg_len
238 .\"O was less than the
239 .\"O .I mq_msgsize
240 .\"O attribute of the message queue.
241 .I msg_len
242 ¤¬¥á¥Ã¥»¡¼¥¸¥­¥å¡¼¤Î
243 .I mq_msgsize
244 °À­¤è¤ê¤â¾®¤µ¤«¤Ã¤¿¡£
245 .TP
246 .B ETIMEDOUT
247 .\"O The call timed out before a message could be transferred.
248 ¥á¥Ã¥»¡¼¥¸¤¬Å¾Á÷¤µ¤ì¤ëÁ°¤Ë´Ø¿ô¸Æ¤Ó½Ð¤·¤¬¥¿¥¤¥à¥¢¥¦¥È¤·¤¿¡£
249 .\"O .SH CONFORMING TO
250 .SH ½àµò
251 POSIX.1-2001.
252 .\"O .SH NOTES
253 .SH Ãí°Õ
254 .\"O On Linux,
255 .\"O .BR mq_timedreceive ()
256 .\"O is a system call, and
257 .\"O .BR mq_receive ()
258 .\"O is a library function layered on top of that system call.
259 Linux ¤Ç¤Ï¡¢
260 .BR mq_timedreceive ()
261 ¤Ï¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¤¢¤ë¡£
262 .BR mq_receive ()
263 ¤Ï¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Ç¡¢
264 .BR mq_timedreceive ()
265 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤òÍѤ¤¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
266 .\"O .SH "SEE ALSO"
267 .SH ´ØÏ¢¹àÌÜ
268 .BR mq_close (3),
269 .BR mq_getattr (3),
270 .BR mq_notify (3),
271 .BR mq_open (3),
272 .BR mq_send (3),
273 .BR mq_unlink (3),
274 .BR mq_overview (7),
275 .BR time (7)