mq_open — create or open a message queue
mqd_t mq_open(const char *name,
* [mode_t mode, struct mq_attr]
The ANSI C ", ...
" construct specifies a variable length argument list
whose optional members are given in the associated comment
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.
argument points to the message queue name, and must conform to the rules
Message Queue Naming Convention.
argument is the bitwise inclusive OR of the flags listed in
The new message queue descriptor returned, remains open across the
system call and is inherited by the child process.
The value of
must be composed by taking the inclusive OR of exactly one of the following
Open for receiving only.
Open for sending only.
Open for sending and receiving.
Any combination of the following flags may also be used in setting the value of
This flag must be used to create a message queue, and it uses two additional
which is of type
which is a pointer to a
If a message queue with name,
exists, this flag has no effect, except as noted under
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 permission bits" will be
set to the value of
is NULL, the message queue is created with default attributes -
is non-NULL and the message queue
attributes are set to the values of the corresponding members in the
structure referred to by
are set in
and the named message queue exists,
flag is ignored if
is not set in
This flag is used to specify the blocking status of the message queue
descriptor and determines whether a
will wait for resources or messages respectively, that are not currently
available, or fail with
Message Queue Naming Convention
A valid message queue name string, must conform to path name construction
In addition it must also meet the following specifications:
Begin with a slash character.
Contain no path name component consisting of a dot or dot-dot.
Contain no illegal characters.
Contain no path name components longer that
Entire name should not be longer that
To use this function, link in the realtime library by specifying
on the compiler or linker command line.
Some or all of the actions associated with this system call are subject to
for more information about compartmentalization on systems that support
Compartmental restrictions can be overridden if the process possesses the
Processes owned by the superuser may not have this privilege.
Processes owned by any user may have this privilege, depending on system
Some or all of the actions associated with this system call require the
Processes owned by the superuser have this privilege.
Processes owned by other users may have this privilege, depending on system
for more information about privileged access on
systems that support fine-grained privileges.
returns the following values:
is a message queue descriptor for the opened message queue and is greater
than or equal to
is set to indicate the error.
is set to one of the following values:
The message queue exists and the permissions specified by
are denied, or the message queue does not exist and permission to create
the queue is denied.
flags are set in
and the named message queue exists.
was interrupted by a signal.
does not conform to the
Message Queue Naming Convention.
has been specified in
the value of
is not NULL, and either
is less than or equal to zero.
Too many message queue descriptors are currently in use by this process.
The length of the
bytes, or the length of a (path name) component of the
is in effect.
Too many message queues are currently open in the system.
flag is not set in
and the named message queue does not exist.
There are insufficient resources for the creation of the new message queue.
is not supported by the implementation.
mq_open(): POSIX 1003.1b