Remove queues opened by a process that dies

Hi,
does anyone know how to automaticcaly remove queues from the /dev/mqueue
directory. I have a process openning a queue. When it terminates
normally the queue is removed. I have noticed that when the queue
terminates abnormally, the queue remains in /dev/mqueue. Any ideas as to
how this queue can be removed automaticaly?

Padraig Furlong

Padraig Furlong <Padraig.Furlong@rte.ie> wrote:

does anyone know how to automaticcaly remove queues from the /dev/mqueue
directory. I have a process openning a queue. When it terminates
normally the queue is removed. I have noticed that when the queue
terminates abnormally, the queue remains in /dev/mqueue. Any ideas as to
how this queue can be removed automaticaly?

Hmmm … this “should not happen”. A mq_open(O_CREAT) should create a
reference to a message queue that is persistent beyond a task death,
until a corresponding mq_unlink() removes the name. Can you provide
a source example where this does not hold true … ?

John Garvey <jgarvey@qnx.com> wrote:

Padraig Furlong <> Padraig.Furlong@rte.ie> > wrote:
does anyone know how to automaticcaly remove queues from the /dev/mqueue
directory. I have a process openning a queue. When it terminates
normally the queue is removed. I have noticed that when the queue
terminates abnormally, the queue remains in /dev/mqueue. Any ideas as to
how this queue can be removed automaticaly?

Hmmm … this “should not happen”. A mq_open(O_CREAT) should create a
reference to a message queue that is persistent beyond a task death,
until a corresponding mq_unlink() removes the name. Can you provide
a source example where this does not hold true … ?

If, in the normal case, there is cleanup code that does a “mq_unlink()”,
then this would happen.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

John,
I should have said
When the process terminates abnormally the queue that was opened
remains in /dev/mqueue

Padraig

John Garvey wrote:

Padraig Furlong <> Padraig.Furlong@rte.ie> > wrote:

does anyone know how to automaticcaly remove queues from the /dev/mqueue
directory. I have a process openning a queue. When it terminates
normally the queue is removed. I have noticed that when the queue
terminates abnormally, the queue remains in /dev/mqueue. Any ideas as to
how this queue can be removed automaticaly?


Hmmm … this “should not happen”. A mq_open(O_CREAT) should create a
reference to a message queue that is persistent beyond a task death,
until a corresponding mq_unlink() removes the name. Can you provide
a source example where this does not hold true … ?

Padraig Furlong <Padraig.Furlong@rte.ie> wrote:

John,
I should have said
When the process terminates abnormally the queue that was opened
remains in /dev/mqueue

As John said, that is normal and expected behaviour. There isn’t a
way for it to go away automatically.

If it goes away when your process terminates normally, that is likely
because your process has cleanup code in its normal termination path
that explicitly unlinks the mqueue.

If you really need that behaviour, you’ll have to do it externally
somehow… have a starter process that watches for this processes
death, and if it dies, have it explicitly unlink the mqueue or
something similar.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.