HPlogo MPE/iX Developer's Kit Reference Manual Volume 2: HP 3000 MPE/iX Computer Systems > Chapter 2 SVID IPC Library Function Descriptions

msgget

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Returns a message queue identifier.

Syntax

   #include <sys/types.h>

   #include <sys/ipc.h>

   #include <sys/msg.h>



   int msgget (key_t key, int msgflg);

Parameters

key

Either a user-defined key value to rendezvous with the message queue, or IPC_PRIVATE. If IPC_PRIVATE is specified, a new message queue is created, but other processes cannot rendezvous by key. Refer to the description of ftok() for details about obtaining user-defined key values

msgflg

Valid flags for this function are:

IPC_CREAT

If a message queue is not already associated with key, a new message queue identifier is allocated and a message queue and data structure are associated with it. If a message queue identifier is already associated with key, and IPC_EXCL is not specified, msgget() returns the message queue identifier associated with key.

IPC_EXCL

If specified with IPC_CREAT, msgget() returns an error if a message queue identifier is already associated with key.

MODE

The lower nine bits of msgflg contain access permission bits (similar to the nine-bit mask found in file entries). They define access permissions for the owner, the group, and other users on the system.

Return Values

>0

Success. A message queue identifier is returned.

-1

An error occurred, and errno is set to indicate the error condition.

Description

The msgget() function returns a message queue identifier associated with the value passed in key. A new message queue identifier is allocated and a message queue and data structure are associated with it if:

  • The value passed in key is equal to IPC_PRIVATE.

  • The value passed in key does not already have a message queue identifier associated with it, and msgflg specifies IPC_CREAT.

The data structure associated with the new message queue identifier is initialized to the following values:

msg_perm.cuid

Effective user ID of the calling process (creator user ID)

msg_perm.uid

Effective user ID of the calling process (owner user ID)

msg_perm.cgid

Effective group ID of the calling process (creator group ID)

msg_perm.gid

Effective group ID of the calling process (owner group ID)

msg_perm.mode

Low-order 9 bits are set equal to the low-order 9 bits of msgflg

msg_qnum

Zero

msg_lspid

Zero

msg_lrpid

Zero

msg_stime

Zero

msg_rtime

Zero

msg_ctime

Current time

msg_qbytes

System limit

Implementation Considerations

The maximum size of a message is 65536 bytes.

An MPE/iX system manager can use the MPE/iX SVIPC utility to interactively configure:

  • The maximum message size

  • The maximum number of bytes on a message queue

  • The total number of message queues allowed system wide

Refer to the section "Managing SVID IPC Services" for more information.

Errors

If an error occurs, errno is set to one of the following values.

EACCESCAUSEA message queue identifier exists for key and the calling process does not have permission (specified by the low-order 9 bits of msgflg).
ACTIONEnsure that the calling process has appropriate permissions to access the existing message queue associated with key, or specify a unique key value to create a new message queue. 
EEXISTCAUSEA message queue identifier exists for key and msgflg specifies both IPC_CREATE and IPC_EXCL.
ACTIONTo access the existing message queue associated with key, remove the IPC_EXCL option. Otherwise, a unique key value must be specified. 
ENOENTCAUSEA message queue identifier does not exist for key and msgflg does not specify IPC_CREATE.
ACTIONSpecify IPC_CREATE to indicate a message queue should be created if one does not already exist for the specified key value. 
ENOSPCCAUSEThe number of message queue identifiers would exceed the system-defined limit.
ACTIONA new message queue cannot be created unless a previously allocated message queue is removed. 
ESYSERRCAUSEAn operating system error occurred that does not map directly to any of the above errors.
ACTIONExamine the MPE/iX process error stack for the type of system error. 

See Also

msgctl(), msgrcv(), msgsnd(), SVID2 (Section 12)

Feedback to webmaster