We can check the details of system V message queue with the help of ipcscommand. Is there any command to check POSIX message queue in Linux?

3 Answers 3


If you're lucky enough to use HP-UX, the command pipcs (PDF) (sorry link broken, no current archive, see this man page on unix.com instead) performs the POSIX equivalent to the SysV IPC ipcs command. Sadly, it has never appeared for other OS's. The current (January 2021) util-linux package which provides ipcs barely mentions POSIX mqueues.

If you have mqueue mounted on /dev/mqueue, what is supported is reading metadata for an existing queue as a file:

user@linux $ sudo mount -t mqueue mqueue /dev/mqueue
user@linux $ mq_create -c /myQ
user@linux $ cat /dev/mqueue/myQ
QSIZE:0          NOTIFY:0     SIGNO:0     NOTIFY_PID:0 

The QSIZE is sadly only the size in bytes, not messages; on Linux there is (as yet, kernel 5.4) no message count field – unlike FreeBSD which provides a CURMSG value:

user@freebsd $ cat /mnt/mqueue/myQ
QSIZE:0          MAXMSG:32         CURMSG:0          MSGSIZE:1024   

So the answer should be "mount the mqueue FS and use cat", but it's not :(

(Mounting the mqueue FS is not a prerequisite for using the MQ API, it just lets you do some "everything is a file" stuff.)

There is good coverage of message queues in the book The Linux Programming Interface, including C source code for various CLI tools to create, inspect and use message queues. Happily chapter 52 of the book which covers this topic is currently available free to download. See pmsg_getattr.c.

The canonical reference code from Stephen's Unix Network Programming (Vol 2) 2nd Ed. (1999) is available here, it provides amongst other things mqgetattr which will do the job too (though you'll likely need to massage a couple of lines in the top level config.h, the #define's for various uint types conflict with contemporary Unix system headers).

There are also Ruby, Perl and TCL modules for this, the Ruby one comes with a posix-mq-rb CLI tool.

  • I using ubuntu system..
    – sujin
    Apr 15, 2013 at 18:18

$ ipcs -q will provide message queue stats from the command line.

$ ipcs -m will provide shared memory stats from the command line.

$ ipcs will provide all ipc mechanism stats.

  • 11
    ipcs is not for POSIX1 message queues
    – whoan
    Nov 1, 2016 at 5:46
  • 4
    ipcs is used for System V message queues and not for POSIX message queues
    – Yerke
    Jul 7, 2018 at 22:21

There is no command I know of but there exists a libc function call which can get the statistics:

man 3 mq_getattr

   mq_getattr() returns an mq_attr structure  in  the  buffer  pointed  by
   attr.  This structure is defined as:

       struct mq_attr {
           long mq_flags;       /* Flags: 0 or O_NONBLOCK */
           long mq_maxmsg;      /* Max. # of messages on queue */
           long mq_msgsize;     /* Max. message size (bytes) */
           long mq_curmsgs;     /* # of messages currently in queue */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.