Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (k - m) msgget(2)
The msg_ctime eld is set to the current time. This eld is updated when any of the fol-
lowing events occur:
The message queue identier is created.
The message queue identier is removed.
The msg_qbytes eld is set to the system limit.
The message queue identier is used for the following purposes:
It identies a specic message server.
It allows detection of references to a previously removed message queue.
It allows detection of attempts to reference message queues in other processors.
Key Creation
The key represents a user-designated name for a given message queue. Keys are usually selected
by calling the ftok() function before calling the msgget() function. The ftok( ) function returns a
key based on a path and an interprocess communications identier. This key is passed to the
msgget() function, which returns a message queue identier.
The message queue identier is then used in calls to the msgctl(), msgrcv(), and msgsnd()
functions.
Uniqueness of Identiers
The system recycles no-longer-used message queue identiers after a long time elapses.
Processor or Disk Process Failures
If a processor fails and if its OSS message-queue server was running as a process pair, no queued
messages are lost. The backup server process takes over, and there are no effects on the success-
ful completion of this function.
If the OSS message-queue server was not running as a process pair when its processor failed,
queued messages are lost and the function call fails with errno set to [EINVAL]. Thereafter, a
process cannot successfully call any function using the associated message queue identier.
Cleaning Up Message Queue Identiers
A message queue identier remains allocated until it is removed. An allocated message queue
identier is not removed when the last process using it terminates. The user must remove allo-
cated message queue identiers that are not attached to processes to avoid wasting system
resources.
The status of message queue identiers can be checked with the ipcs command. Message queue
identiers can be removed using the ipcrm command. The associated data structure is removed
only after the nal detach operation.
Message Queue Use Between Environments
Guardian processes cannot use OSS functions for access to OSS message queues. Such a call
fails, and errno is set to [ENOTOSS].
RETURN VALUES
Upon successful completion, a message queue identier is returned. Otherwise, the value -1 is
returned and errno is set to indicate the error.
527186-003 Hewlett-Packard Company 437