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>
28 .\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.13
30 .TH MQ_RECEIVE 3 2010-09-20 "Linux" "Linux Programmer's Manual"
33 .\"O mq_receive, mq_timedreceive \- receive a message from a message queue
34 mq_receive, mq_timedreceive \- メッセージキューからメッセージを受信する
38 .B #include <mqueue.h>
40 .BI "ssize_t mq_receive(mqd_t " mqdes ", char *" msg_ptr ,
41 .BI " size_t " msg_len ", unsigned *" msg_prio );
44 .B #include <mqueue.h>
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 );
51 .\"O Link with \fI\-lrt\fP.
56 .\"O Feature Test Macro Requirements for glibc (see
57 .\"O .BR feature_test_macros (7)):
59 .RB ( feature_test_macros (7)
63 .BR mq_timedreceive ():
65 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
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
74 .\"O and places it in the buffer pointed to by
79 で参照されるメッセージキューから最も高い優先度を持つ
80 最も古いメッセージを削除し、そのメッセージを
85 .\"O argument specifies the size of the buffer pointed to by
87 .\"O this must be greater than the
89 .\"O attribute of the queue (see
90 .\"O .BR mq_getattr (3)).
94 が指すバッファの大きさを示す。この値はキューの
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.
106 が指すバッファに受信したメッセージの優先度が格納される。
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.
114 .\"O flag is enabled for the message queue description,
115 .\"O then the call instead fails immediately with the error
119 は、新しいメッセージが届くか、関数呼び出しがシグナルハンドラにより
120 中断されるまで、停止 (block) する。
121 メッセージキュー記述 (message queue description) で
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
134 .\"O flag is not enabled for the message queue description, then
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 ()
145 メッセージキューが空で、メッセージキュー記述で
147 フラグが有効になっていない場合に、この呼び出しが停止する時間の上限を
149 が指す構造体で指定する点が異なる。この上限は、タイムアウトの時刻を、
150 時刻紀元 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) からの経過時間
151 (秒とナノ秒の組) で指定する。タイムアウト時刻は以下の構造体で指定する:
156 .\"O time_t tv_sec; /* seconds */
157 .\"O long tv_nsec; /* nanoseconds */
158 time_t tv_sec; /* 秒 */
159 long tv_nsec; /* ナノ秒 */
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 メッセージがキューになく、関数呼び出し時にすでにタイムアウト時刻が
170 .BR mq_timedreceive ()
172 .\"O .SH RETURN VALUE
175 .\"O .BR mq_receive ()
177 .\"O .BR mq_timedreceive ()
178 .\"O return the number of bytes in the received message;
179 .\"O on error, \-1 is returned, with
181 .\"O set to indicate the error.
185 .BR mq_timedreceive ()
194 .\"O The queue was empty, and the
196 .\"O flag was set for the message queue description referred to by
205 .\"O The descriptor specified in
212 .\"O The call was interrupted by a signal handler; see
214 関数呼び出しがシグナルハンドラにより中断された。
219 .\"O The call would have blocked, and
221 .\"O was invalid, either because
223 .\"O was less than zero, or because
225 .\"O was less than zero or greater than 1000 million.
234 が 0 未満か 1,000,000,000 より大きい、ということである。
238 .\"O was less than the
240 .\"O attribute of the message queue.
247 .\"O The call timed out before a message could be transferred.
248 メッセージが転送される前に関数呼び出しがタイムアウトした。
249 .\"O .SH CONFORMING TO
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.
260 .BR mq_timedreceive ()
264 .BR mq_timedreceive ()