What happens when a process reads an IPC message with msgrcv
?
Why I can't read a message with the same mtype
more than once?
Code for the structure being used:
struct msgbuff{
long mtype;
char mtext[150];
};
A message can only be read once. This is how the msgrcv manpage describes its function:
The msgrcv() system call removes a message from the queue specified by msqid and places it in the buffer pointed to by msgp.
There is no way to peek at the queue. If you need that you could pop an item from the queue with msgrcv() and then add it again using msgsnd(). There is a risk that will fail (queue full, out of memory, etc.) so it is not foolproof.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With