OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / release / 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 .SH 名前
32 mq_send, mq_timedsend \- メッセージキューにメッセージを送信する
33 .SH 書式
34 .nf
35 .B #include <mqueue.h>
36 .sp
37 .BI "int mq_send(mqd_t " mqdes ", const char *" msg_ptr ,
38 .BI "              size_t " msg_len ", unsigned " msg_prio );
39 .sp
40 .B #include <time.h>
41 .B #include <mqueue.h>
42 .sp
43 .BI "int mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr ,
44 .BI "              size_t " msg_len ", unsigned " msg_prio ,
45 .BI "              const struct timespec *" abs_timeout );
46 .fi
47 .sp
48 \fI\-lrt\fP でリンクする。
49 .sp
50 .ad l
51 .in -4n
52 glibc 向けの機能検査マクロの要件
53 .RB ( feature_test_macros (7)
54 参照):
55 .in
56 .sp
57 .BR mq_timedsend ():
58 .RS 4
59 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
60 .RE
61 .ad
62 .SH 説明
63 .BR mq_send ()
64 は、記述子
65 .I mqdes
66 で参照されるメッセージキューに
67 .I msg_ptr
68 が指すメッセージを追加する。
69 .I msg_len
70 引き数は、
71 .I msg_ptr
72 が指すメッセージの長さを示す。この長さはキューの
73 .I mq_msgsize
74 属性以下でなければならない。
75 長さが 0 のメッセージも認められている。
76
77 .I msg_prio
78 引き数は、メッセージの優先度を指定する負でない整数である。
79 メッセージは優先度の降順でキューに格納され、同じ優先度の新しいメッセージは
80 同じ優先度の古いメッセージの後ろに格納される。
81
82 メッセージキューがすでに一杯の場合
83 (すなわち、キューに入っているメッセージ数がキューの
84 .I mq_maxmsg
85 属性と等しい場合)、デフォルトでは、
86 .B mq_send ()
87 は、メッセージをキューイングするのに十分な空間ができるか、
88 関数呼び出しがシグナルハンドラにより中断されるまで、停止 (block) する。
89 メッセージキュー記述 (message queue description) で
90 .B O_NONBLOCK
91 フラグが有効になっている場合は、
92 .BR mq_send ()
93 はエラー
94 .B EAGAIN
95 ですぐに失敗する。
96
97 .BR mq_timedsend ()
98
99 .BR mq_send ()
100 と全く同じ動作をするが、
101 メッセージキューが一杯で、メッセージキュー記述で
102 .B O_NONBLOCK
103 フラグが有効になっていない場合に、この呼び出しが停止する時間の上限を
104 .I abs_timeout
105 が指す構造体で指定する点が異なる。この上限は、タイムアウトの時刻を
106 時刻紀元 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) からの経過時間
107 (秒とナノ秒の組) で指定する。タイムアウト時刻は以下の構造体で指定する:
108 .sp
109 .in +4n
110 .nf
111 struct timespec {
112     time_t tv_sec;        /* 秒 */
113     long   tv_nsec;       /* ナノ秒 */
114 };
115
116 .fi
117 .in
118 メッセージキューが一杯で、関数呼び出し時にすでにタイムアウト時刻が
119 過ぎている場合、
120 .BR mq_timedsend ()
121 はすぐに返る。
122 .SH 返り値
123 成功すると、
124 .BR mq_send ()
125
126 .BR mq_timedsend ()
127 は 0 を返す。
128 エラーの場合、\-1 を返し、
129 .I errno
130 にエラーを示す値を設定する。
131 .SH エラー
132 .TP
133 .B EAGAIN
134 キューが一杯で、かつ
135 .I mqdes
136 で参照されるメッセージキュー記述で
137 .B O_NONBLOCK
138 フラグがセットされていた。
139 .TP
140 .B EBADF
141 .I mqdes
142 で指定された記述子が不正である。
143 .TP
144 .B EINTR
145 関数呼び出しがシグナルハンドラにより中断された。
146 .BR signal (7)
147 参照。
148 .TP
149 .B EINVAL
150 関数呼び出しは停止するはずであったが、
151 .I abs_timeout
152 が不正であった。
153 .I abs_timeout
154 が不正とは、
155 .I tv_sec
156 が 0 未満、もしくは
157 .I tv_nsec
158 が 0 未満か 1,000,000,000 より大きい、ということである。
159 .TP
160 .B EMSGSIZE
161 .I msg_len
162 がメッセージキューの
163 .I mq_msgsize
164 属性よりも大きかった。
165 .TP
166 .B ETIMEDOUT
167 メッセージが転送される前に関数呼び出しがタイムアウトした。
168 .SH 準拠
169 POSIX.1-2001.
170 .SH 注意
171 Linux では、
172 .BR mq_timedsend ()
173 はシステムコールである。
174 .BR mq_send ()
175 はライブラリ関数で、
176 .BR mq_timedsend ()
177 システムコールを用いて実装されている。
178 .SH 関連項目
179 .BR mq_close (3),
180 .BR mq_getattr (3),
181 .BR mq_notify (3),
182 .BR mq_open (3),
183 .BR mq_receive (3),
184 .BR mq_unlink (3),
185 .BR mq_overview (7),
186 .BR time (7)