Controlling a Message Queue

The initial examination of the message queue will concern control functions such as message queue creation, modification, and destruction. Message sending and receiving is covered later.

Creating Message Queues

The last chapter provided a sneak peek at the message queue creation process. The function synopsis is repeated here for your convenience:

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

int msgget(key_t key, int flags);

The argument key must have the value IPC_PRIVATE or a valid IPC key value.

The flags argument must contain the permission bits for the new queue and IPC_CREAT if the queue is being created. The flag IPC_EXCL can be added to cause msgget(3) to return an error if the message ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.