.\" Copyright (C) 2006 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved. .\" Translated 2006-04-23, Akihiro MOTOKI .\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.13 .\" .TH MQ_SEND 3 2020\-08\-13 Linux "Linux Programmer's Manual" .SH 名前 mq_send, mq_timedsend \- メッセージキューにメッセージを送信する .SH 書式 .nf \fB#include \fP .PP \fBint mq_send(mqd_t \fP\fImqdes\fP\fB, const char *\fP\fImsg_ptr\fP\fB,\fP \fB size_t \fP\fImsg_len\fP\fB, unsigned int \fP\fImsg_prio\fP\fB);\fP .PP \fB#include \fP \fB#include \fP .PP \fBint mq_timedsend(mqd_t \fP\fImqdes\fP\fB, const char *\fP\fImsg_ptr\fP\fB,\fP \fB size_t \fP\fImsg_len\fP\fB, unsigned int \fP\fImsg_prio\fP\fB,\fP \fB const struct timespec *\fP\fIabs_timeout\fP\fB);\fP .fi .PP \fI\-lrt\fP でリンクする。 .PP .ad l .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBmq_timedsend\fP(): .RS 4 _POSIX_C_SOURCE\ >=\ 200112L .RE .ad .SH 説明 \fBmq_send\fP() は、メッセージキュー記述子 \fImqdes\fP で参照されるメッセージキューに \fImsg_ptr\fP が指すメッセージを追加する。 \fImsg_len\fP 引数は、 \fImsg_ptr\fP が指すメッセージの長さを示す。この長さはキューの \fImq_msgsize\fP 属性以下でなければならない。 長さが 0 のメッセージも認められている。 .PP \fImsg_prio\fP 引数は、メッセージの優先度を指定する負でない整数である。 メッセージは優先度の降順でキューに格納され、同じ優先度の新しいメッセージは 同じ優先度の古いメッセージの後ろに格納される。メッセージの優先度の範囲については \fBmq_overview\fP(7) を参照。 .PP メッセージキューがすでに一杯の場合 (すなわち、キューに入っているメッセージ数がキューの \fImq_maxmsg\fP 属性と等しい場合)、デフォルトでは、 \fBmq_send ()\fP は、メッセージをキューイングするのに十分な空間ができるか、 関数呼び出しがシグナルハンドラーにより中断されるまで、停止 (block) する。 メッセージキュー記述 (message queue description) で \fBO_NONBLOCK\fP フラグが有効になっている場合は、 \fBmq_send\fP() はエラー \fBEAGAIN\fP ですぐに失敗する。 .PP \fBmq_timedsend\fP() behaves just like \fBmq_send\fP(), except that if the queue is full and the \fBO_NONBLOCK\fP flag is not enabled for the message queue description, then \fIabs_timeout\fP points to a structure which specifies how long the call will block. This value is an absolute timeout in seconds and nanoseconds since the Epoch, 1970\-01\-01 00:00:00 +0000 (UTC), specified in the following structure: .PP .in +4n .EX struct timespec { time_t tv_sec; /* 秒 */ long tv_nsec; /* ナノ秒 */ }; .EE .in .PP メッセージキューが一杯で、関数呼び出し時にすでにタイムアウト時刻が 過ぎている場合、 \fBmq_timedsend\fP() はすぐに返る。 .SH 返り値 成功すると、 \fBmq_send\fP() と \fBmq_timedsend\fP() は 0 を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP にエラーを示す値を設定する。 .SH エラー .TP \fBEAGAIN\fP キューが一杯で、かつ \fImqdes\fP で参照されるメッセージキュー記述で \fBO_NONBLOCK\fP フラグがセットされていた。 .TP \fBEBADF\fP The descriptor specified in \fImqdes\fP was invalid or not opened for writing. .TP \fBEINTR\fP 関数呼び出しがシグナルハンドラーにより中断された。 \fBsignal\fP(7) 参照。 .TP \fBEINVAL\fP 関数呼び出しは停止するはずであったが、 \fIabs_timeout\fP が不正であった。 \fIabs_timeout\fP が不正とは、 \fItv_sec\fP が 0 未満、もしくは \fItv_nsec\fP が 0 未満か 1,000,000,000 より大きい、ということである。 .TP \fBEMSGSIZE\fP \fImsg_len\fP がメッセージキューの \fImq_msgsize\fP 属性よりも大きかった。 .TP \fBETIMEDOUT\fP メッセージが転送される前に関数呼び出しがタイムアウトした。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lbw25 lb lb l l l. インターフェース 属性 値 T{ \fBmq_send\fP(), \fBmq_timedsend\fP() T} Thread safety MT\-Safe .TE .SH 準拠 POSIX.1\-2001, POSIX.1\-2008. .SH 注意 Linux では、 \fBmq_timedsend\fP() はシステムコールである。 \fBmq_send\fP() はライブラリ関数で、 \fBmq_timedsend\fP() システムコールを用いて実装されている。 .SH 関連項目 \fBmq_close\fP(3), \fBmq_getattr\fP(3), \fBmq_notify\fP(3), \fBmq_open\fP(3), \fBmq_receive\fP(3), \fBmq_unlink\fP(3), \fBmq_overview\fP(7), \fBtime\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。