send a message to a process associated with a file descriptor
#include <sys/kernel.h> int Sendfd( int fd, void *smsg, void *rmsg, unsigned snbytes, unsigned rnbytes );
The kernel function Sendfd() sends a message pointed to by smsg to the process associated with fd. Any reply is placed in the message buffer pointed to by rmsg. The maximum size of the sent message is snbytes, while the size of the reply is truncated to a maximum of rnbytes. The file descriptor fd must have been returned by a call to qnx_fd_attach() (which open() calls). The kernel uses the fd to index into the kernel file descriptor table and replace the fd with a process id. At this point the Sendfd() becomes equivalent to a Send().
This call is used heavily by the I/O library to direct messages to the appropriate resource manager based upon a file descriptor (for example, read()). You should only need to use it if you write your own resource manager that implements an extended set of messages not provided by the standard library.
The number of bytes transferred is the minimum of that specified by both the sender and the receiver. The send data isn't allowed to overflow the receive buffer area provided by the receiver, nor can the receiver read past the end of the sender's buffer.
After sending a message, the sending process becomes blocked, waiting for a reply. If the receiving process is receive-blocked and ready to receive the message, the transfer of data into its address space occurs immediately, the receiver is unblocked and made ready to run, and the sending process enters the REPLY BLOCKED state. If the receiver isn't ready to receive the message, the sender becomes SEND BLOCKED, and is placed in a queue (perhaps with other processes), and the transfer doesn't occur until the receiving task does a receive.
If specified process doesn't exist, or dies while the sender is BLOCKED on it then Sendfd() returns -1, and errno is set to ESRCH.
Sendfd() may be interrupted by a signal, in which case it returns -1, and errno is set to EINTR.
Sendfd() is a simple cover function that builds two single-part _mxfer_entry structures on the stack, and calls Sendfdmx(), which is the real kernel function. It's provided for convenience, since it's easier to use than Sendfdmx() for simple messages.
See Sendfdmx().
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
Sendfd() is a macro.
Creceive(), Creceivemx(), errno, Receive(), Receivemx(), Reply(), Replymx(), Readmsg(), Readmsgmx(), Send(), Sendfdmx(), Sendmx(), Writemsg(), Writemsgmx(), Trigger()