[Previous]
[Contents]
[Next]

Readmsg()

read a message from another process

Synopsis:

#include <sys/kernel.h>
unsigned Readmsg( pid_t pid, unsigned offset,
                  void *msg, unsigned nbytes );

Description:

The kernel function Readmsg() reads nbytes of data into a buffer pointed to by msg from the process identified by pid. The offset allows you to read data from the sender's send message starting at any point. The data transfer occurs immediately, and your task doesn't block. The state of the process pid isn't changed.

The process pid must have sent a message that was received and not yet replied to. It must be in the REPLY BLOCKED state.

If you attempt to read past the end of the sender's message, Readmsg() will return fewer bytes than was specified by nbytes.

Readmsg() is a simple cover function that builds a single part _mxfer_entry on the stack, and calls Readmsgmx(), which is the real kernel function. It's provided for convenience, since it's easier to use than Readmsgmx() for simple messages. Please read the documentation for Readmsgmx() for examples on when to use it.

Returns:

The number of bytes read. On error, -1 is returned and errno is set.

Errors:

EFAULT
In order to complete the message exchange the current process would have incurred a segment violation. You need to make your buffer(s) larger or limit the number of bytes allowed in the transfer.
EINTR
Call interrupted by a signal.
ESRCH
The process pid doesn't exist.

Examples:

See Sendmx().

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

Caveats:

Readmsg() is a macro.

See also:

Creceive(), Creceivemx(), errno, Receive(), Receivemx(), Reply(), Replymx(), Readmsgmx(), Send(), Sendfd(), Sendfdmx(), Sendmx(), Writemsg(), Writemsgmx(), Trigger()


[Previous]
[Contents]
[Next]