OSDN Git Service

be812b5c5bb7ea63a3351fc31e483400792d1819
[linuxjm/LDP_man-pages.git] / draft / man3 / mq_send.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_SEND 3 2010-09-20 "Linux" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH 名前
33 .\"O mq_send, mq_timedsend \- send a message to a message queue
34 mq_send, mq_timedsend \- メッセージキューにメッセージを送信する
35 .\"O .SH SYNOPSIS
36 .SH 書式
37 .nf
38 .B #include <mqueue.h>
39 .sp
40 .BI "int mq_send(mqd_t " mqdes ", const 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 "int mq_timedsend(mqd_t " mqdes ", const 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_timedsend ():
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_send ()
71 .\"O adds the message pointed to by
72 .\"O .I msg_ptr
73 .\"O to the message queue referred to by the descriptor
74 .\"O .IR mqdes .
75 .\"O The
76 .\"O .I msg_len
77 .\"O argument specifies the length of the message pointed to by
78 .\"O .IR msg_ptr ;
79 .\"O this length must be less than or equal to the queue's
80 .\"O .I mq_msgsize
81 .\"O attribute.
82 .\"O Zero-length messages are allowed.
83 .BR mq_send ()
84 は、記述子
85 .I mqdes
86 で参照されるメッセージキューに
87 .I msg_ptr
88 が指すメッセージを追加する。
89 .I msg_len
90 引き数は、
91 .I msg_ptr
92 が指すメッセージの長さを示す。この長さはキューの
93 .I mq_msgsize
94 属性以下でなければならない。
95 長さが 0 のメッセージも認められている。
96
97 .\"O The
98 .\"O .I msg_prio
99 .\"O argument is a nonnegative integer that specifies the priority
100 .\"O of this message.
101 .\"O Messages are placed on the queue in decreasing order of priority,
102 .\"O with newer messages of the same priority being placed after
103 .\"O older messages with the same priority.
104 .I msg_prio
105 引き数は、メッセージの優先度を指定する負でない整数である。
106 メッセージは優先度の降順でキューに格納され、同じ優先度の新しいメッセージは
107 同じ優先度の古いメッセージの後ろに格納される。
108
109 .\"O If the message queue is already full
110 .\"O (i.e., the number of messages on the queue equals the queue's
111 .\"O .I mq_maxmsg
112 .\"O attribute), then, by default,
113 .\"O .BR mq_send ()
114 .\"O blocks until sufficient space becomes available to allow the message
115 .\"O to be queued, or until the call is interrupted by a signal handler.
116 .\"O If the
117 .\"O .B O_NONBLOCK
118 .\"O flag is enabled for the message queue description,
119 .\"O then the call instead fails immediately with the error
120 .\"O .BR EAGAIN .
121 メッセージキューがすでに一杯の場合
122 (すなわち、キューに入っているメッセージ数がキューの
123 .I mq_maxmsg
124 属性と等しい場合)、デフォルトでは、
125 .B mq_send ()
126 は、メッセージをキューイングするのに十分な空間ができるか、
127 関数呼び出しがシグナルハンドラにより中断されるまで、停止 (block) する。
128 メッセージキュー記述 (message queue description) で
129 .B O_NONBLOCK
130 フラグが有効になっている場合は、
131 .BR mq_send ()
132 はエラー
133 .B EAGAIN
134 ですぐに失敗する。
135
136 .\"O .BR mq_timedsend ()
137 .\"O behaves just like
138 .\"O .BR mq_send (),
139 .\"O except that if the queue is full and the
140 .\"O .B O_NONBLOCK
141 .\"O flag is not enabled for the message queue description, then
142 .\"O .I abs_timeout
143 .\"O points to a structure which specifies a ceiling on the time for which
144 .\"O the call will block.
145 .\"O This ceiling is an absolute timeout in seconds and nanoseconds
146 .\"O since the Epoch, 1970-01-01 00:00:00 +0000 (UTC), and it is
147 .\"O specified in the following structure:
148 .BR mq_timedsend ()
149
150 .BR mq_send ()
151 と全く同じ動作をするが、
152 メッセージキューが一杯で、メッセージキュー記述で
153 .B O_NONBLOCK
154 フラグが有効になっていない場合に、この呼び出しが停止する時間の上限を
155 .I abs_timeout
156 が指す構造体で指定する点が異なる。この上限は、タイムアウトの時刻を
157 時刻紀元 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) からの経過時間
158 (秒とナノ秒の組) で指定する。タイムアウト時刻は以下の構造体で指定する:
159 .sp
160 .in +4n
161 .nf
162 struct timespec {
163 .\"O     time_t tv_sec;        /* seconds */
164 .\"O     long   tv_nsec;       /* nanoseconds */
165     time_t tv_sec;        /* 秒 */
166     long   tv_nsec;       /* ナノ秒 */
167 };
168
169 .fi
170 .in
171 .\"O If the message queue is full,
172 .\"O and the timeout has already expired by the time of the call,
173 .\"O .BR mq_timedsend ()
174 .\"O returns immediately.
175 メッセージキューが一杯で、関数呼び出し時にすでにタイムアウト時刻が
176 過ぎている場合、
177 .BR mq_timedsend ()
178 はすぐに返る。
179 .\"O .SH RETURN VALUE
180 .SH 返り値
181 .\"O On success,
182 .\"O .BR mq_send ()
183 .\"O and
184 .\"O .BR mq_timedsend ()
185 .\"O return zero; on error, \-1 is returned, with
186 .\"O .I errno
187 .\"O set to indicate the error.
188 成功すると、
189 .BR mq_send ()
190
191 .BR mq_timedsend ()
192 は 0 を返す。
193 エラーの場合、\-1 を返し、
194 .I errno
195 にエラーを示す値を設定する。
196 .\"O .SH ERRORS
197 .SH エラー
198 .TP
199 .B EAGAIN
200 .\"O The queue was full, and the
201 .\"O .B O_NONBLOCK
202 .\"O flag was set for the message queue description referred to by
203 .\"O .IR mqdes .
204 キューが一杯で、かつ
205 .I mqdes
206 で参照されるメッセージキュー記述で
207 .B O_NONBLOCK
208 フラグがセットされていた。
209 .TP
210 .B EBADF
211 .\"O The descriptor specified in
212 .\"O .I mqdes
213 .\"O was invalid.
214 .I mqdes
215 で指定された記述子が不正である。
216 .TP
217 .B EINTR
218 .\"O The call was interrupted by a signal handler; see
219 .\"O .BR signal (7).
220 関数呼び出しがシグナルハンドラにより中断された。
221 .BR signal (7)
222 参照。
223 .TP
224 .B EINVAL
225 .\"O The call would have blocked, and
226 .\"O .I abs_timeout
227 .\"O was invalid, either because
228 .\"O .I tv_sec
229 .\"O was less than zero, or because
230 .\"O .I tv_nsec
231 .\"O was less than zero or greater than 1000 million.
232 関数呼び出しは停止するはずであったが、
233 .I abs_timeout
234 が不正であった。
235 .I abs_timeout
236 が不正とは、
237 .I tv_sec
238 が 0 未満、もしくは
239 .I tv_nsec
240 が 0 未満か 1,000,000,000 より大きい、ということである。
241 .TP
242 .B EMSGSIZE
243 .\"O .I msg_len
244 .\"O was greater than the
245 .\"O .I mq_msgsize
246 .\"O attribute of the message queue.
247 .I msg_len
248 がメッセージキューの
249 .I mq_msgsize
250 属性よりも大きかった。
251 .TP
252 .B ETIMEDOUT
253 .\"O The call timed out before a message could be transferred.
254 メッセージが転送される前に関数呼び出しがタイムアウトした。
255 .\"O .SH CONFORMING TO
256 .SH 準拠
257 POSIX.1-2001.
258 .\"O .SH NOTES
259 .SH 注意
260 .\"O On Linux,
261 .\"O .BR mq_timedsend ()
262 .\"O is a system call, and
263 .\"O .BR mq_send ()
264 .\"O is a library function layered on top of that system call.
265 Linux では、
266 .BR mq_timedsend ()
267 はシステムコールである。
268 .BR mq_send ()
269 はライブラリ関数で、
270 .BR mq_timedsend ()
271 システムコールを用いて実装されている。
272 .\"O .SH "SEE ALSO"
273 .SH 関連項目
274 .BR mq_close (3),
275 .BR mq_getattr (3),
276 .BR mq_notify (3),
277 .BR mq_open (3),
278 .BR mq_receive (3),
279 .BR mq_unlink (3),
280 .BR mq_overview (7),
281 .BR time (7)