[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

kmsgget Kernel Service

Purpose

Obtains a message queue identifier.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int kmsgget (key, msgflg, msqid)
key_t key;
int msgflg;
int *msqid;

Parameters

key Specifies either a value of IPC_PRIVATE or an IPC key constructed by the ftok subroutine (or a similar algorithm).
msgflg Specifies that the msgflg parameter is constructed by logically ORing one or more of these values:
IPC_CREAT Creates the data structure if it does not already exist.
IPC_EXCL Causes the kmsgget kernel service to fail if IPC_CREAT is also set and the data structure already exists.
S_IRUSR Permits the process that owns the data structure to read it.
S_IWUSR Permits the process that owns the data structure to modify it.
S_IRGRP Permits the process group associated with the data structure to read it.
S_IWGRP Permits the process group associated with the data structure to modify it.
S_IROTH Permits others to read the data structure.
S_IWOTH Permits others to modify the data structure.

The values that begin with S_I... are defined in the /usr/include/sys/stat.h file. They are a subset of the access permissions that apply to files.

msqid A reference parameter where a valid message-queue ID is returned if the kmsgget kernel service is successful.

Description

The kmsgget kernel service returns the message-queue identifier specified by the msqid parameter associated with the specified key parameter value. The kmsgget kernel service provides the same functions for user-mode processes in kernel mode as the msgget subroutine performs for kernel processes or user-mode processes in user mode. The kmsgget service can be called by a user-mode process in kernel mode or by a kernel process. A kernel process can also call the msgget subroutine to provide the same function.

Execution Environment

The kmsgget kernel service can be called from the process environment only.

Return Values

0 Indicates successful completion. The msqid parameter is set to a valid message-queue identifier.

If the kmsgget kernel service fails, the msqid parameter is not valid and the return code is one of these four values:

EACCES Indicates that a message queue ID exists for the key parameter but operation permission as specified by the msgflg parameter cannot be granted.
ENOENT Indicates that a message queue ID does not exist for the key parameter and the IPC_CREAT command is not set.
ENOSPC Indicates that a message queue ID is to be created but the system-imposed limit on the maximum number of allowed message queue IDs systemwide will be exceeded.
EEXIST Indicates that a message queue ID exists for the value specified by the key parameter, and both the IPC_CREAT and IPC_EXCL commands are set.

Implementation Specifics

The kmsgget kernel service is part of Base Operating System (BOS) Runtime.

Related Information

The msgget subroutine.

Message Queue Kernel Services and Understanding System Call Execution in AIX Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]