mq_getattrのヘルプ・マニュアル
日本語 英語
mq_getattr --help
man mq_getattr
MQ_GETATTR(3) Linux Programmer’s Manual MQ_GETATTR(3)
名前
mq_getattr, mq_setattr - メッセージキューの属性を設定/取得する
書式
#include
mqd_t mq_getattr(mqd_t mqdes, struct mq_attr *attr);
mqd_t mq_setattr(mqd_t mqdes, struct mq_attr *newattr,
struct mq_attr *oldattr);
-lrt でリンクする。
説明
mq_getattr() と mq_setattr() は、記述子 mqdes で参照されるメッセージキ
ューの属性の取得と変更をそれぞれ行う。
mq_getattr() は、 attr が指すバッファに mq_attr 構造体を格納して返す 。
この構造体は以下のように定義されている:
struct mq_attr {
long mq_flags; /* フラグ: 0 か O_NONBLOCK */
long mq_maxmsg; /* キューの最大メッセージ数 */
long mq_msgsize; /* 最大メッセージサイズ (バイト単位) */
long mq_curmsgs; /* キューに現在入っているメッセージ数 */
};
mq_flags フ ィ ールドには、オープンメッセージキュー記述 (open message
queue description) に関連付けられているフラグが格納される。このフィール
ド は mq_open(3) でキューが作成される際に初期化される。このフィールドに
現れるフラグは O_NONBLOCK だけである。
mq_maxmsg と mq_msgsize フィールドは mq_open(3) でメッセージキューが 作
成される際にセットされる。 mq_maxmsg フィールドは、 mq_send(3) を使って
キューに入れることができるメッセージ数の上限である。 mq_msgsize フィ ー
ル ドは、キューに入れることができるメッセージの上限サイズである。これら
のフィールドはどちらも 0 より大きな値でなければならない。これらのフィー
ル ドに設定できる値の上限は /proc ファイルにより決まる。 /proc ファイル
の詳細は mq_open(3) に説明されている。
mq_curmsgs フィールドはキューに現在格納されているメッセージ数を返す。
mq_setattr() は、 newattr が指す mq_attr 構造体で与えられた情報を使って
、 メ ッ セ ー ジ キ ューの属性を設定する。変更することができる属性は、
mq_flags の O_NONBLOCK フラグの設定だけである。 newattr の他のフィー ル
ドは無視される。 oldattr フィールドが NULL 以外の場合、 mq_getattr() が
返すのと同じ情報を格納した mq_attr 構造体を oldattr が指すバッファに 入
れて返す。
返り値
成 功 すると、 mq_getattr () と mq_setattr () は 0 を返す。エラーの場合
、-1 を返し、 errno にエラーを示す値を設定する。
エラー
EBADF mqdes で指定された記述子が不正である。
EINVAL newattr->mq_flags に O_NONBLOCK 以外のビットがセットされていた。
準拠
POSIX.1-2001.
注意
Linux で は 、 mq_getattr() と mq_setattr() はライブラリ関数であり、
mq_getsetattr(2) システムコールを用いて実装されている。
関連項目
mq_close(3), mq_notify(3), mq_open(3), mq_receive(3), mq_send(3),
mq_unlink(3), mq_overview(7)
Linux 2008-09-29 MQ_GETATTR(3)
MQ_GETATTR(3) Linux Programmer’s Manual MQ_GETATTR(3)
NAME
mq_getattr, mq_setattr - get/set message queue attributes
SYNOPSIS
#include
mqd_t mq_getattr(mqd_t mqdes, struct mq_attr *attr);
mqd_t mq_setattr(mqd_t mqdes, struct mq_attr *newattr,
struct mq_attr *oldattr);
Link with -lrt.
DESCRIPTION
mq_getattr() and mq_setattr() respectively retrieve and modify
attributes of the message queue referred to by the descriptor mqdes.
mq_getattr() returns an mq_attr structure in the buffer pointed by
attr. This structure is defined as:
struct mq_attr {
long mq_flags; /* Flags: 0 or O_NONBLOCK */
long mq_maxmsg; /* Max. # of messages on queue */
long mq_msgsize; /* Max. message size (bytes) */
long mq_curmsgs; /* # of messages currently in queue */
};
The mq_flags field contains flags associated with the open message
queue description. This field is initialized when the queue is created
by mq_open(3). The only flag that can appear in this field is O_NON-
BLOCK.
The mq_maxmsg and mq_msgsize fields are set when the message queue is
created by mq_open(3). The mq_maxmsg field is an upper limit on the
number of messages that may be placed on the queue using mq_send(3).
The mq_msgsize field is an upper limit on the size of messages that may
be placed on the queue. Both of these fields must have a value greater
than zero. Two /proc files that place ceilings on the values for these
fields are described in mq_open(3).
The mq_curmsgs field returns the number of messages currently held in
the queue.
mq_setattr() sets message queue attributes using information supplied
in the mq_attr structure pointed to by newattr. The only attribute
that can be modified is the setting of the O_NONBLOCK flag in mq_flags.
The other fields in newattr are ignored. If the oldattr field is not
NULL, then the buffer that it points to is used to return an mq_attr
structure that contains the same information that is returned by
mq_getattr().
RETURN VALUE
On success mq_getattr() and mq_setattr() return 0; on error, -1 is
returned, with errno set to indicate the error.
ERRORS
EBADF The descriptor specified in mqdes is invalid.
EINVAL newattr->mq_flags contained set bits other than O_NONBLOCK.
CONFORMING TO
POSIX.1-2001.
NOTES
On Linux, mq_getattr() and mq_setattr() are library functions layered
on top of the mq_getsetattr(2) system call.
SEE ALSO
mq_close(3), mq_notify(3), mq_open(3), mq_receive(3), mq_send(3),
mq_unlink(3), mq_overview(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-09-29 MQ_GETATTR(3)