Read a message from the message queue specified by ecx into the ipc_kludge pointed to by the edi argument, removing the read message from the queue.
Arguments
ecx |
Message queue ID. |
edx |
Maximum size in bytes for the member mtext of the structure pointed to by theipc_kludge.msgp argument. If the message text has length greater than edx, then the behavior depends on whether MSG_NOERROR is specified in ebp. If MSG_NOERROR is specified, then the message text will be truncated (and the truncated part will be lost); if MSG_NOERROR is not specified, then the message isn't removed from the queue and the system call fails returning -E2BIG. |
esi |
Specifies the type of message requested and may be either:
0 |
The the first message in the queue is read. |
< 0 |
Then the first message in the queue of type esi is read, unless MSG_EXCEPT was specified in ebp, in which case the first message in the queue of type not equal to esi will be read. |
< 0 |
Then the first message in the queue with the lowest type less than or equal to the absolute value of esi will be read. |
|
|
edi |
Pointer to a properly initialized ipc_kludge structure:
struc ipc_kludge
{
.msgp rd 1
.msgtyp rd 1
} |
msgp should point to a caller-defined structure of the following general form:
struc msgbuf
.mtype rd 1 ; message type
.mtext rb 1 ; message data
ends |
|
ebp |
Operation flag:
IPC_NOWAIT |
For immediate return if no message of the requested type is in the queue. The system call fails with -ENOMSG. |
MSG_EXCEPT |
Used with esi greater than 0 to read the first message in the queue with message type that differs from edi. |
MSG_NOERROR |
To truncate the message text if longer than edx bytes. |
|
Return values
If the function succeeds the return value is the number of bytes actually copied into the mtext array.
If the function fails the return value is one of the following errno values:
-E2BIG |
The message text length is greater than edx and MSG_NOERROR isn't specified in ebp. |
-EACCES |
The calling process does not have read permission on the message queue, and does not have the CAP_IPC_OWNER capability. |
-EFAULT |
The address pointed to by edi isn't accessible. |
-EIDRM |
While the process was sleeping to receive a message, the message queue was removed. |
-EINTR |
While the process was sleeping to receive a message, the process caught a signal. |
-EINVAL |
ecx was invalid, or edx was less than 0. |
-ENOMSG |
IPC_NOWAIT was specified in ebp and no message of the requested type existed on the message queue. |
|
Remarks
If no message of the requested type is available and IPC_NOWAIT isn't specified in ebp, the calling process is blocked until one of the following conditions occurs:
- A message of the desired type is placed in the queue.
- The message queue is removed from the system. In this case the system call fails with -EIDRM.
- The calling process catches a signal. In this case the system call fails with -EINTR.
Upon successful completion the message queue data structure is updated as follows:
msg_lrpid is set to the process ID of the calling process.
msg_qnum is decremented by 1.
msg_rtime is set to the current time.
See /samples/ipc/msg.asm for an example. |