How about
Code:
message_queue = msgget(ftok("/tmp", 100), 0666);
to get a handle back to the message queue?
The message queue details are stored in internal kernel structures. You can use
msgctl(index,MSG_STAT,&info) to find information on all existing message queues. You need to scan with
index starting from zero, increasing by one, until the call returns -1 with
errno==EINVAL (for no more message queues). The key used for the
msgget() call (
ftok("/tmp",100)) is in
info.msg_perm.__key.
You can use the
ipcs -q command to list all message queues, and
ipcrm -Q key or
ipcrm -q id to delete a message queue.
This is all documented in the
man 2 msgget and
man 2 msgctl man pages.
Hope this helps,