mq_open(2)mq_open(2)NAMEmq_open - create or open a message queue
SYNOPSIS
Remarks
The ANSI C "" construct specifies a variable length argument list whose
optional members are given in the associated comment
DESCRIPTION
The system call establishes a connection between a process and a mes‐
sage 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
The oflag argument is the bitwise inclusive OR of the flags listed in
and below.
The new message queue descriptor returned, remains open across the sys‐
tem call and is inherited 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:
Open for receiving only.
Open for sending only.
Open for sending and receiving.
General Flags
Any combination of the following flags may also be used in setting the
value of oflag.
This flag must be used to create a message queue, and it uses
two additional
arguments: mode which is of type and attr which
is a pointer to a structure. If a message queue
with name, name, exists, this flag has no effect,
except as noted under 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
permission bits" will be set to the value of
mode. If attr is NULL, the message queue is cre‐
ated with default attributes - and (defined in If
attr is non-NULL and the message queue mq_maxmsg
and mq_msgsize attributes are set to the values
of the corresponding members in the structure
referred to by attr.
If and are set in oflag and the named message queue
exists, will fail. The flag is ignored if is not
set in oflag.
This flag is used to specify the blocking status of the message
queue
descriptor and determines whether a or a will
wait for resources or messages respectively, that
are not currently available, or fail with set to
Message Queue Naming Convention
A valid message queue name string, must conform to path name construc‐
tion rules. In addition it must also meet the following specifica‐
tions:
a. Begin with a slash character.
b. Contain no path name component consisting of a dot or dot-
dot. For example, and are invalid.
c. Contain no illegal characters.
d. Contain no path name components longer that
e. 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.
Security Restrictions
Some or all of the actions associated with this system call are subject
to compartmental restrictions. See compartments(5) for more informa‐
tion about compartmentalization on systems that support that feature.
Compartmental restrictions can be overridden if the process possesses
the privilege Processes owned by the superuser may not have this privi‐
lege. Processes owned by any user may have this privilege, depending
on system configuration.
Some or all of the actions associated with this system call require the
privilege Processes owned by the superuser have this privilege. Pro‐
cesses owned by other users may have this privilege, depending on sys‐
tem configuration.
See privileges(5) for more information about privileged access on sys‐
tems that support fine-grained privileges.
RETURN VALUE
returns the following values:
n Successful completion. n is a message queue descriptor for
the opened message queue and is greater than or equal to
Failure.
is set to indicate the error.
ERRORS
If fails, is set to one of the following values:
The message queue exists and the permissions specified by
oflag are denied, or the message queue does not
exist and permission to create the queue is
denied.
The and flags are set in oflag and the named message
queue exists.
was interrupted by a signal.
The argument name, does not conform to the
has been specified in oflag, the value of attr is
not NULL, and either mq_maxmsg or mq_msgsize is
less than or equal to zero.
Too many message queue descriptors are currently in use by this
process.
The length of the
name string exceeds bytes, or the length of a
(path name) component of the name string exceeds
bytes while is in effect.
Too many message queues are currently open in the system.
The flag is not set in oflag 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.
SEE ALSOmq_close(2), mq_getattr(2), mq_receive(2), mq_send(2), mq_setattr(2),
mq_unlink(2), privileges(5).
STANDARDS CONFORMANCEmq_open(2)