System V Messages

Before a process can send or receive a message, you must initialize the queue through msgget(). The owner or creator of a queue can change its ownership or permissions using msgctl(). Any process with permission can use msgctl() for control operations. For more information, see the msgget(2) and msgctl(2) man pages.

IPC messaging enables processes to send and receive messages and queue messages for processing in an arbitrary order. Unlike the file byte-stream data flow of pipes, each IPC message has an explicit length.

Messages can be assigned a specific type. A server process can direct message traffic between clients on its queue by using the client process PID as the message type. For single-message transactions, multiple server processes can work in parallel on transactions sent to a shared message queue.

Operations to send and receive messages are performed by msgsnd() and msgrcv(), respectively. When a message is sent, its text is copied to the message queue. msgsnd() and msgrcv() can be performed as either blocking or non-blocking operations. For more information, see the msgsnd(2) and msgrcv(2) man pages.

A blocked message operation remains suspended until one of the following three conditions occurs:

  • The call succeeds

  • The process receives a signal

  • The queue is removed