mq_open.2 (2010 09)

m
mq_open(2) mq_open(2)
NAME
mq_open - create or open a message queue
SYNOPSIS
#include <sys/mqueue.h>
mqd_t mq_open(const char *name,
int oflag,...
/*
* [mode_t mode, struct mq_attr]
*/
);
Remarks
The ANSI C ", ..." construct specifies a variable length argument list whose optional members are
given in the associated comment (/* */
).
DESCRIPTION
The
mq_open() system call establishes a connection between a process and a message queue. It returns
a new message queue descriptor which is used by other message queue system calls to refer to that queue.
The name argument points to the message queue name, and must conform to the rules listed in Message
Queue Naming Convention .
The oflag argument is the bitwise inclusive OR of the flags listed in Read-Write Flags , and General Flags
below.
The new message queue descriptor returned, remains open across the
fork() system call and is inher-
ited by the child process.
Read-Write Flags
The value of oflag must be composed by taking the inclusive OR of exactly one of the following flags:
O_RDONLY Open for receiving only.
O_WRONLY Open for sending only.
O_RDWR Open for sending and receiving.
General Flags
Any combination of the following flags may also be used in setting the value of oflag.
O_CREAT This flag must be used to create a message queue, and it uses two additional argu-
ments: mode which is of type mode_t, and attr which is a pointer to a mq_attr
structure. If a message queue with name, name, exists, this flag has no effect,
except as noted under O_EXCL. Otherwise a new message queue is created. The
user ID of the queue will be set to the effective user ID of the process, and the group
ID of the queue will be set to the effective group ID of the process. The "file permis-
sion bits" will be set to the value of mode.Ifattr is NULL, the message queue is
created with default attributes - MQ_MAXMSG and MQ_MSGSIZE (defined in
sys/mqueue.h)Ifattr is non-NULL and the message queue mq_maxmsg and
mq_msgsize attributes are set to the values of the corresponding members in the
mq_attr structure referred to by attr .
O_EXCL If O_EXCL and O_CREAT are set in oflag and the named message queue exists,
mq_open() will fail. The O_CREAT flag is ignored if O_CREAT is not set in oflag.
O_NONBLOCK This flag is used to specify the blocking status of the message queue descriptor and
determines whether a mq_send() or a mq_receive() will wait for resources or
messages respectively, that are not currently available, or fail with errno set to
[EAGAIN].
Message Queue Naming Convention
A valid message queue name string, must conform to path name construction rules. In addition it must
also meet the following specifications:
a. Begin with a slash character.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)