How can I clear the IPC message queue?

I am using a feature msgget()in an IPC based application. How to clear a queue filled with old message queues?

+3
source share
4 answers

To delete a queue, use the following command:

msgctl(msgQID, IPC_RMID, NULL);

SYSTEM CALL: msgctl ()

+5
source

Works to increase MSGMNI Maximum number of message queues in the system: it depends on the policy (in Linux this restriction can be read and changed using / proc / sys / kernel / msgmni ).

+1
source

O_NONBLOCK mq_setattr. , , , . .

This method is not optimized for runtime, but it avoids the need to close and open the message queue.

+1
source

These persistent resource allocation problems (there are similar with shared memory) are why System V APIs are generally considered deprecated. In this case, have you considered using a unix or FIFO domain socket instead of a message queue? They appear on the file system and can be "cleaned up" when they are no longer used with tools like rm.

0
source

Source: https://habr.com/ru/post/1719910/


All Articles