msgget(2) DG/UX 4.30 msgget(2)
NAME
msgget - Get message queue identifier.
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int msgget (key, msgflg)
key_t key;
int msgflg;
PARAMETERS
key A user-defined name for the message queue.
msgflg 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.
The newly created message queue can be shared among
other processes by distributing the message queue
identifier.
A process can make multiple msgget operations
Licensed material--property of copyright holder(s) Page 1
msgget(2) DG/UX 4.30 msgget(2)
specifying IPC_PRIVATE. The identifiers 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
<msgflg> are clear and <key> is not IPC_PRIVATE.
The message 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
<msgflg>, an error is returned.
* Create only if <key> is not already defined.
In this case, the IPC_CREAT and IPC_EXCL bits of
<msgflg> 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 <msgflg> is set, the
IPC_EXCL bit of <msgflg> 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 set to the low-order 9 bits of
<msgflg>.
* The current size (msg_cbytes), the process id
Licensed material--property of copyright holder(s) Page 2
msgget(2) DG/UX 4.30 msgget(2)
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 initial 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
<msqid> 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 <msgflg>.
EEXIST Both the IPC_CREAT and IPC_EXCL bits of
<msgflg> 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 <msgflg> is not set.
ENOSPC Creating a new message queue would cause the
system-imposed limit on the number of message
queues to be exceeded.
SEE ALSO
intro(2), ipcrm(1), ipcs(1), msgctl(2), msgrcv(2),
msgsnd(2).
Licensed material--property of copyright holder(s) Page 3