Open System Services System Calls Reference Manual (G06.25+, H06.03+)
msgget(2) OSS System Calls Reference Manual
NAME
msgget - Creates or returns the identifier for a message queue
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
H-series OSS processes: /G/system/zdllnnn/zosskdll
SYNOPSIS
#include <sys/msg.h>
int msgget(
key_t key,
int msgflg);
PARAMETERS
key Specifies the key that identifies the message queue. The IPC_PRIVATE key can
be used to ensure the return of a new (unused) message queue identifier.
msgflg Specifies the following creation flag values:
IPC_CREAT If the key does not exist, the msgget() function creates a mes-
sage queue identifier using the given key.
IPC_CREAT | IPC_EXCL
If the key already exists, the msgget() function fails and returns
an error notification.
DESCRIPTION
The msgget() function returns the message queue identifier for the message queue identified by
the key parameter. If the key parameter already has a message queue identifier associated with it
and (msgflg & IPC_CREAT) is 0 (zero), that identifier is returned.
A new message queue identifier and its associated data structure are created when either of the
following is true:
• The value of IPC_PRIVATE is used for the key parameter.
• The key parameter does not already have a message queue identifier associated with it,
and (msgflg & IPC_CREAT) is not 0 (zero).
After creating a new message queue identifier, the msgget() function initializes the msqid_ds
structure associated with the identifier as follows:
• The msg_perm.cuid and msg_perm.uid fields are set to the effective user ID of the cal-
ling process.
• The msg_perm.cgid and msg_perm.gid fields are set to the effective group ID of the
calling process.
• The low-order nine bits of the msg_perm.mode field are set to the low-order nine bits of
msgflg.
• The msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime fields are all set to
0 (zero).
4−36 Hewlett-Packard Company 527186-003