msgrcv() - read message from a message queue
#include <sys/msg.h>
int msgrcv (int msqid, void *msgp, size_t msgsz,
long int msgtyp, int msgflg);
The msgrcv(2) function retrieves a message from the queue associated with the identifier msqid. The message is stored in a user-defined structure indicated by msgp (see msgsnd(2)) and is of the size specified by msgsz.
The type of message to be received is specified by the argument msgtyp. The msgrcv(2) function searches through the queue for messages of that type; if msgtyp is 0, the function returns the first message in the queue. If msgtyp is <0, the function returns the first message whose type is less than or equal to the absolute value of msgtyp.
The msgflg describes what is to be done if there is no message of the appropriate type in the queue:
Once the function has received a message, the function changes the data structure associated with msqid in these ways:
On success, the msgrcv(2) function returns the number of bytes placed into the data buffer of the msgp structure. On failure it returns -1 and sets errno to indicate the error.
msgctl(2)
msgget(2)
msgsnd(2)