Next: , Previous: msgsnd, Up: Messages



1.5.3 msgrcv

     int msgrcv (int msqid, struct msgbuf *msgp, int msgsz, long msgtyp,
     			int msgflg);

The first message that meets the msgtyp specification is identified. For msgtyp < 0, the entire queue is searched for the message with the smallest type.

If its length is smaller than msgsz or if the user specified the MSG_NOERROR flag, its text and type are copied to msgp->mtext and msgp->mtype, and it is taken off the queue.

The msg_cbytes, msg_qnum, msg_lrpid, and msg_rtime fields are updated. Writers waiting on the queue are awakened.

Errors:
E2BIG : msg bigger than msgsz and MSG_NOERROR not specified.
EACCES : Do not have permission for reading the queue.
EFAULT : msgp not accessible.
EIDRM : msg queue was removed.
EINTR : msg not found ... would have slept but ... was interrupted.
EINVAL : msgsz > msgmax or msgsz < 0, msqid < 0 or unused.
ENOMSG : msg of requested type not found and IPC_NOWAIT specified.