Открыть очередь сообщений
#include <mqueue.h>mqd_t mq_open( const char *name,int oflag,... );
O_RDWR(send-receive). In addition, you can OR in the following constants to produce the following effects:
O_CREAT, and a message queue name exists, the call fails and errno is set to
EEXIST. Otherwise, the queue is created normally. If you set
O_CREAT, it's ignored.
EAGAINand the call returns an error.
O_CREATin the oflag argument, you must also pass thise argument. The file permissions for the new queue. For more information, see Access permissions. If you set any bits other than file permission bits, they're ignored. Read and write permissions are analogous to receive and send permissions; execute permissions are ignored.
O_CREATin the oflag argument, you must also pass thise argument. NULL, or a pointer to an struct mq_attr that contains the attributes that you want to use for the new queue. For more information, see mq_getattr(). If mq_attr is
NULL, the following default attributes are used — depending on which implementation of message queues you're using — provided that you didn't override the defaults when you started the message-queue server. Attributes:
NULL, the new queue adopts the mq_maxmsg and mq_msgsize of mq_attr. The mq_flags flags field is ignored.
The mq_open() function opens a message queue referred to by name, and returns a message queue descriptor by which the queue can be referenced in the future.
|Neutrino supports two implementations of message queues: a traditional implementation, and an alternate one that uses asynchronous messages. For more information, see the entries for mq and mqueue.|
The name is interpreted as follows:
|name||Pathname space entry|
/dev/mq(or the path specified with the -N option to mq):
/dev/mq. For example, if your current directory is
|name||Pathname space entry|
| If you want to open a queue on another node, you have to use the traditional (mqueue) implementation and specify the name as |
If name doesn't exist, mq_open() examines the third and fourth parameters: a
mode_t and a pointer to an struct mq_attr.
The only time that a call to mq_open() with
O_CREAT set fails is if you open a message queue and later unlink it, but never close it. Like their file counterparts, an unlinked queue that hasn't yet been closed must continue to exist; an attempt to recreate such a message queue fails, and errno is set to
|Message queues persist — like files — even after the processes that created them end. A message queue is destroyed when the last process connected to it unlinks from the queue by calling mq_unlink().|
A valid message queue descriptor if the queue is successfully created.
Если возникла ошибка функция возвращает
-1, код ошибки записывается в errno.
O_EXCLflags in oflag, and the queue name exists.
O_CREATflag in oflag, and mq_attr wasn't
NULL, but some values in the struct mq_attr were invalid.
O_CREATflag, and the queue name doesn't exist.
POSIX 1003.1 MSG
struct stat, struct mq_attr, mq_close(), mq_getattr(), mq_notify(), mq_receive(), mq_send(), mq_setattr(), mq_timedreceive(), mq_timedsend(), mq_unlink()
mq, mqueue в Справочнике по Утилитам
Предыдущий раздел: Описание API системной библиотеки