A message queue is allocated by a msgget system call :
msqid = msgget (key_t key, int msgflg);
key
: an integer usually got from ftok()
or IPC_PRIVATE.
msgflg
:
A message queue is allocated if there is no resource corresponding
to the given key. The access permissions specified are then copied
into the msg_perm
struct and the fields in msqid_ds
initialized. The user must use the IPC_CREAT flag or key = IPC_PRIVATE,
if a new instance is to be allocated. If a resource corresponding to
key already exists, the access permissions are verified.
Errors:
EACCES : (procure) Do not have permission for requested access.
EEXIST : (allocate) IPC_CREAT | IPC_EXCL specified and resource exists.
EIDRM : (procure) The resource was removed.
ENOSPC : All id's are taken (max of MSGMNI id's system-wide).
ENOENT : Resource does not exist and IPC_CREAT not specified.
ENOMEM : A new msqid_ds
was to be created but ... nomem.