kmsgsnd Kernel Service

Purpose

Sends a message using a previously defined message queue.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/ipc.h>
#include <sys/msg.h>

int kmsgsnd (msqid, msgp, msgsz, msgflg)
int  msqid;
struct msgbuf *  msgp;
int  msgsz, msgflg;

Parameters

Item Description
msqid Specifies the message queue ID that indicates which message queue the message is to be sent on.
msgp Points to an msgbuf structure containing the message. The msgbuf structure is defined in the /usr/include/sys/msg.h file.
msgsz Specifies the size of the message to be sent in bytes. The msgsz parameter can range from 0 to a system-imposed maximum.
msgflg Specifies the action to be taken if the message cannot be sent for one of several reasons.

Description

The kmsgsnd kernel service sends a message to the queue specified by the msqid parameter. The kmsgsnd kernel service provides the same functions for user-mode processes in kernel mode as the msgsnd subroutine performs for kernel processes or user-mode processes in user mode. The kmsgsnd service can be called by a user-mode process in kernel mode or by a kernel process. A kernel process can also call the msgsnd subroutine to provide the same function.

There are two reasons why the kmsgsnd kernel service cannot send the message:

There are several actions to take when the kmsgsnd kernel service cannot send the message:

Execution Environment

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

The calling process must have write permission to perform the kmsgsnd operation.

Return Values

Item Description
0 Indicates a successful operation.
EINVAL Indicates that the msqid parameter is not a valid message queue ID.
EACCES Indicates that operation permission is denied to the calling process.
EAGAIN Indicates that the message cannot be sent for one of the reasons stated previously, and the msgflg parameter is set to IPC_NOWAIT.
EINVAL Indicates that the msgsz parameter is less than 0 or greater than the system-imposed limit.
EINTR Indicates that the kmsgsnd service received a signal.
EIDRM Indicates that the message queue ID specified by the msqid parameter has been removed from the system.
ENOMEM Indicates that the system does not have enough memory to send the message.