Pipe vs msg queue

ipc, linux

Solution

Off the top of my head and assuming you talk about posix message queues (not the SysV ones):

- Pipes aren't limited in size, message queues are.

- Pipes can be integrated in systems using file descriptors, message queues have their own set of functions, though linux supports `select()`, `poll()`, `epoll()` and friends on the `mqd_t`.

- Pipes, once closed, require some amount of cooperation on both sides to reestablish them, message queues can be closed and reopened on either side without the coorporation of the other side.

- Pipes are flat, much like a stream, to impose a message structure you would have to implement a protocol on both sides, message queues are message oriented already, no care has to be taken to get, say, the fifth message in the queue.

Problem

What is the difference between message queues and a pipe in Linux?

Original source

Related problems