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.
source
share