msgsnd [ MPE/iX Developer's Kit Reference Manual Volume II ] MPE/iX 5.0 Documentation
MPE/iX Developer's Kit Reference Manual Volume II
msgsnd
Sends a message to a message queue.
Syntax
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int msgsnd (int msqid, void *msgp, int msgsz,
int msgflg);
Parameters
msqid Passes a message queue identifier returned by a call to
msgget().
msgp Passes a pointer to a buffer whose structure is similar to the
msgbuf example template located in <msg.h>, for example:
struct example_msgbuf {
long mtype; /* message type */
char mtext[your_buffer_size]; /* message text */
};
where your_buffer_size is an integer specifying the size of
the buffer. The mtype field stores a positive integer value
that can be used by a receiving process for message selection
(refer to msgrcv()). The mtext field stores the text of the
message. The size of mtext is specified by the msgsz
argument.
msgsz The size, in bytes, of mtext. Valid values are from 0 to a
system-defined limit.
msgflg Passes a value defining what action to take if [REV BEG]the
number of bytes passed would cause the size of the specified
queue to exceed the system-defined limit (msq_bytes)[REV END],
the total size of message data on this queue would exceed the
system-defined limit, or the system-wide message buffer pool
is temporarily depleted due to the amount of data queued to
all message queues.
Flags are:
IPC_NOWAIT The calling process is not suspended. Control
returns immediately with errno set to EAGAIN.
If msgflg does not specify IPC_NOWAIT [REV BEG]and one of the
previous conditions would occur, the calling process suspends
execution. When the condition that caused the suspension no
longer exists, msgsnd() continues execution.[REV END]
Return Values
0 Success.
-1 An error occurred, and errno is set to indicate the error
condition.
Description
The msgsnd() function sends a message stored in the buffer pointed to by
msgp to the message queue associated with msqid.
If the message queue associated with msqid is removed from the system
while the calling process is suspended waiting to send a message,
msgsnd() returns an error and sets errno to EIDRM .
If msgsnd() is successful, the following fields of the data structure
associated with msqid are updated to the indicated values:
msg_qnum Incremented by 1
msg_lrpid PID of the calling process
msg_rtime Current time
Implementation Considerations
If a process suspended during execution of msgsnd() receives a signal,
control returns to the user with errno set to EINTR. Disabled signals are
ignored.
Errors
If an error occurs, errno is set to one of the following values.
EACCES CAUSE The calling process does not have permission.
ACTION Ensure that the calling process has write permission
for the message queue.
EAGAIN CAUSE msgflg specifies IPC_NOWAIT and either [REV BEG]the
number of bytes passed would cause the size of the
specified queue to exceed the system-defined
limit[REV END], the total size of message data on
this queue would exceed the system-defined limit, or
the system-wide message buffer pool is temporarily
depleted due to the amount of data queued to all
message queues.
ACTION None. Application dependent. The send operation can
be retried later.
EFAULT CAUSE The system detected a NULL or bad address in
attempting to use the msgp argument.
ACTION Check to see if the pointer is correctly initialized.
EIDRM CAUSE The message queue specified by msqid was removed
while msgsnd() was waiting on a message.
ACTION None.
EINTR CAUSE msgsnd() was interrupted by a signal.
ACTION None. Application dependent.
Table 2-0. (cont.)
EINVAL CAUSE msqid is not a valid message queue identifier, or
msgsz is less than 0 or greater than the
system-defined limit, or mtype is less than 0.
ACTION Check the parameters to make sure the msqid is valid
and has not been removed from the system, and that
the msgsz and mtype are within valid ranges.
ESYSERR CAUSE An operating system error occurred that does not map
directly to any of the above errors.
ACTION Examine the MPE/iX process error stack for the type
of system error.
See Also
msgctl(), msgget(), msgrcv(), SVID2 (Section 12)
MPE/iX 5.0 Documentation