msgget(2)
_________________________________________________________________
msgget System Call
Get message queue identifier.
_________________________________________________________________
SYNTAX
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int msgget (key, flag)
key_t key;
int flag;
PARAMETERS
key A user-defined name for the message queue.
flag A set of flags indicating the requested permission
state of the message queue, whether a new message
queue should be created, and whether the message
queue should be held exclusively.
DESCRIPTION
Msgget returns the message queue identifier associated with
<key>.
This message queue identifier may then be used in other message
queue operations as specified by msgctl, msgsnd, and msgrcv.
Msgget can be used to get the message queue identifier of an
existing message queue or to create a new message queue as
follows:
Four options are available:
* Create a private message queue.
In this case, <key> is IPC_PRIVATE.
A process can create a "private" message queue by using the
special IPC_PRIVATE key. The system will create a message
queue identifier that is private to the process. The
message queue identifier will not be returned to other
processes regardless of what key value they specify.
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
msgget(2)
The newly created message queue can be shared among other
processes by distributing the message queue identifier.
A process can make multiple msgget operations specifying
IPC_PRIVATE. The keys returned will be unique and the
associated message queues will be different.
* Find <key> if already defined.
In this case, the IPC_CREAT and IPC_EXCL bits of <flag> are
clear and <key> is not IPC_PRIVATE.
The memory queue identifier associated with the given key is
returned. If none exists or if one exists but the
permission rights of the message queue do not include those
specified by the low-order 9 bits of <flag>, an error is
returned.
* Create only if <key> not already defined.
In this case, the IPC_CREAT and IPC_EXCL bits of <flag> are
both set and <key> is not IPC_PRIVATE.
If a message queue identifier already exists for <key> an
error is returned. Otherwise, a message queue identifier
and associated message queue are created. The message queue
identifier will be returned to other processes that specify
the same key value.
* Find <key> if already defined, otherwise create.
In this case, the IPC_CREAT bit of <flag> is set, the
IPC_EXCL bit of <flag> is clear, and <key> is not
IPC_PRIVATE.
If a message queue identifier already exists for <key>, this
is identical to the second option above. Otherwise, this is
identical to the third option above.
If a new message queue is created, its attributes are initialized
as follows:
* The message queue creator's user id (msg_perm.cuid) and the
message queue's user id (msg_perm.uid) are set to the
effective user id of the calling process.
* The message queue creator's group id (msg_perm.cgid) and the
message queue's group id (msg_perm.gid) are set to the
effective group id of the calling process.
* The message queue's permission rights (in msg_perm.mode) are
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
msgget(2)
set to the low-order 9 bits of <flag>.
* The current size (msg_cbytes), process id performing the
last msgsnd and msgrcv operations (msg_lspid and msg_lrpid),
and the times of the last msgsnd and msgrcv operations
(msg_stime and msg_rtime) are all set to their zero values.
* The most recent time the message queue attributes were
changed (msg_ctime) is set to the current time.
* The maximum size (msg_qbytes) is set to the system limit.
ACCESS CONTROL
See the description of the exception condition EACCES below.
RETURN VALUE
<message-queue-id>
A non-negative integer that identifies the message
queue associated with <key>.
-1 An error occurred. Errno is set to indicate the
error.
EXCEPTIONS
If a message queue exists for <key>, errno may be set to one of
these values:
EACCES The permission rights of the message queue do not
include those specified by the low-order 9 bits of
<flag>.
EEXIST Both the IPC_CREAT and IPC_EXCL bits of <flag> are
set.
If a message queue does not exist for <key>, errno may be set to
one of these values:
ENOENT The IPC_CREAT bit of <flag> is not set.
ENOSPC Creating a new message queue would cause the
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)
msgget(2)
system-imposed limit on the number of message
queues to be exceeded.
SEE ALSO
The related system calls: msgctl, msgrcv, msgsnd.
The related manual section: intro(2).
DG/UX 4.00 Page 4
Licensed material--property of copyright holder(s)