#include <mqueue.h>
ssize_t mq_receive(size_t msg_len;
mqd_t mqdes, char msg_ptr[msg_len],
size_t msg_len, unsigned int *msg_prio);
#include <time.h>
#include <mqueue.h>
ssize_t mq_timedreceive(size_t msg_len;
mqd_t mqdes, char *restrict msg_ptr[msg_len],
size_t msg_len, unsigned int *restrict msg_prio,
const struct timespec *restrict abs_timeout);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
mq_timedreceive():
_POSIX_C_SOURCE >= 200112L
キューが空の場合、デフォルトでは、 mq_receive() は、新しいメッセージが届くか、関数呼び出しがシグナルハンドラーにより 中断されるまで、停止 (block) する。 メッセージキュー記述 (message queue description) で O_NONBLOCK フラグが有効になっている場合は、 mq_receive() はエラー EAGAIN ですぐに失敗する。
mq_timedreceive() behaves just like mq_receive(), except that if the queue is empty and the O_NONBLOCK flag is not enabled for the message queue description, then abs_timeout 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 a timespec(3) structure.
メッセージがキューになく、関数呼び出し時にすでにタイムアウト時刻が 過ぎている場合、 mq_timedreceive() はすぐに返る。
| インターフェース | 属性 | 値 |
| mq_receive(), mq_timedreceive() | Thread safety | MT-Safe |