.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
-.TH MQ_OVERVIEW 7 2015-08-08 "Linux" "Linux Programmer's Manual"
+.TH MQ_OVERVIEW 7 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
mq_overview \- overview of POSIX message queues
.SH DESCRIPTION
.BR msgsnd (2),
.BR msgrcv (2),
etc.), but provides similar functionality.
-
+.PP
Message queues are created and opened using
.BR mq_open (3);
this function returns a
followed by one or more characters, none of which are slashes.
Two processes can operate on the same queue by passing the same name to
.BR mq_open (3).
-
+.PP
Messages are transferred to and from a queue using
.BR mq_send (3)
and
A process can request asynchronous notification
of the arrival of a message on a previously empty queue using
.BR mq_notify (3).
-
+.PP
A message queue descriptor is a reference to an
.I "open message queue description"
-(cf.
+(see
.BR open (2)).
After a
.BR fork (2),
Corresponding message queue descriptors in the two processes share the flags
.RI ( mq_flags )
that are associated with the open message queue description.
-
+.PP
Each message has an associated
.IR priority ,
and messages are always delivered to the receiving process
but the
.BR HARD_MSGMAX
ceiling is nevertheless imposed.
-
+.IP
The definition of
.BR HARD_MSGMAX
has changed across kernel versions:
but the details are likely to differ.)
This filesystem can be mounted (by the superuser) using the following
commands:
+.PP
.in +4n
-.nf
-
+.EX
.RB "#" " mkdir /dev/mqueue"
.RB "#" " mount \-t mqueue none /dev/mqueue"
-
-.fi
+.EE
.in
+.PP
The sticky bit is automatically enabled on the mount directory.
-
+.PP
After the filesystem has been mounted, the message queues on the system
can be viewed and manipulated using the commands usually used for files
(e.g.,
.BR ls (1)
and
.BR rm (1)).
-
+.PP
The contents of each file in the directory consist of a single line
containing information about the queue:
+.PP
.in +4n
-.nf
-
+.EX
.RB "$" " cat /dev/mqueue/mymq"
QSIZE:129 NOTIFY:2 SIGNO:0 NOTIFY_PID:8260
-
-.fi
+.EE
.in
+.PP
These fields are as follows:
.TP
.B QSIZE
.B SIGNO
Signal number to be used for
.BR SIGEV_SIGNAL .
-.SS Polling message queue descriptors
-On Linux, a message queue descriptor is actually a file descriptor,
-and can be monitored using
+.SS Linux implementation of message queue descriptors
+On Linux, a message queue descriptor is actually a file descriptor.
+(POSIX does not require such an implementation.)
+This means that a message queue descriptor can be monitored using
.BR select (2),
.BR poll (2),
or
.BR epoll (7).
This is not portable.
+.PP
+The close-on-exec flag (see
+.BR open (2))
+is automatically set on the file descriptor returned by
+.BR mq_open (2).
.SS IPC namespaces
For a discussion of the interaction of System V IPC objects and
IPC namespaces, see
System V message queues;
on the other hand POSIX message queues are less widely available
(especially on older systems) than System V message queues.
-
+.PP
Linux does not currently (2.6.26) support the use of access control
lists (ACLs) for POSIX message queues.
-.SH EXAMPLE
-An example of the use of various message queue functions is shown in
-.BR mq_notify (3).
.SH BUGS
In Linux versions 3.5 to 3.14, the kernel imposed a ceiling of 1024
.RB ( HARD_QUEUESMAX )
and the ceiling was enforced even for privileged processes.
This ceiling value was removed in Linux 3.14,
and patches to stable kernels 3.5.x to 3.13.x also removed the ceiling.
-
+.PP
As originally implemented (and documented),
the QSIZE field displayed the total number of (user-supplied)
bytes in all messages in the message queue.
(and earlier stable kernel series),
so that the count once more included just the bytes of user data
in messages in the queue.
+.SH EXAMPLE
+An example of the use of various message queue functions is shown in
+.BR mq_notify (3).
.SH SEE ALSO
.BR getrlimit (2),
.BR mq_getsetattr (2),