Gets a message queue identifier.
Standard C Library (libc.a)
int msgget (Key, MessageFlag) key_t Key; int MessageFlag;
The msgget subroutine returns the message queue identifier associated with the specified Key parameter.
A message queue identifier, associated message queue, and data structure are created for the value of the Key parameter if one of the following conditions is true:
Upon creation, the data structure associated with the new message queue identifier is initialized as follows:
The msgget subroutine performs the following actions:
The following limits apply to the message queue:
|Key||Specifies either the value IPC_PRIVATE or an Interprocess Communication (IPC) key constructed by the ftok subroutine (or by a similar algorithm).|
|MessageFlag|| Constructed by logically ORing one or more of the following values:
Values that begin with S_I are defined in the sys/mode.h file and are a subset of the access permissions that apply to files.
Upon successful completion, the msgget subroutine returns a message queue identifier. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The msgget subroutine is unsuccessful if any of the following conditions is true:
|EACCES||A message queue identifier exists for the Key parameter, but operation permission as specified by the low-order 9 bits of the MessageFlag parameter is not granted.|
|ENOENT||A message queue identifier does not exist for the Key parameter and the IPC_CREAT value is not set.|
|ENOSPC||A message queue identifier is to be created, but the system-imposed limit on the maximum number of allowed message queue identifiers system-wide would be exceeded.|
|EEXIST||A message queue identifier exists for the Key parameter, and both IPC_CREAT and IPC_EXCL values are set.|
This subroutine is part of Base Operating System (BOS) Runtime.
The ftok subroutine, msgctl subroutine, msgrcv subroutine, msgsnd subroutine, msgxrcv subroutine.
The mode.h file.