Clearing a Message Queue

Is there any way flush a message queue to get rid of extraneous messages
before using it for the first time?

Thanks,
David Kuechenmeister
david.kuechenmeister@viasat.com

You could stat the message queue for the size, and then do non blocking
receives on it to drain it.


Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>
“David Kuechenmeister” <david.kuechenmeister@viasat.com> wrote in message
news:agmm1r$g50$1@nntp.qnx.com

Is there any way flush a message queue to get rid of extraneous messages
before using it for the first time?

Thanks,
David Kuechenmeister
david.kuechenmeister@viasat.com
\

Is the way to stat a message queue the same as for a file? Just use the
queue id in place of the file pointer and then read the stat structure?

Regards,
David


“Adam Mallory” <amallory@qnx.com> wrote in message
news:agmqsh$jeq$1@nntp.qnx.com

You could stat the message queue for the size, and then do non blocking
receives on it to drain it.


Cheers,
Adam

QNX Software Systems Ltd.
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net
“David Kuechenmeister” <> david.kuechenmeister@viasat.com> > wrote in message
news:agmm1r$g50$> 1@nntp.qnx.com> …
Is there any way flush a message queue to get rid of extraneous messages
before using it for the first time?

Thanks,
David Kuechenmeister
david.kuechenmeister@viasat.com



\

You can stat an fd you’ve created (usually via open() on the message queue
name).


Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>
“David Kuechenmeister” <david.kuechenmeister@viasat.com> wrote in message
news:agmu6t$lt6$1@nntp.qnx.com

Is the way to stat a message queue the same as for a file? Just use the
queue id in place of the file pointer and then read the stat structure?

Regards,
David


“Adam Mallory” <> amallory@qnx.com> > wrote in message
news:agmqsh$jeq$> 1@nntp.qnx.com> …
You could stat the message queue for the size, and then do non blocking
receives on it to drain it.


Cheers,
Adam

QNX Software Systems Ltd.
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net
“David Kuechenmeister” <> david.kuechenmeister@viasat.com> > wrote in
message
news:agmm1r$g50$> 1@nntp.qnx.com> …
Is there any way flush a message queue to get rid of extraneous
messages
before using it for the first time?

Thanks,
David Kuechenmeister
david.kuechenmeister@viasat.com





\

David Kuechenmeister <david.kuechenmeister@viasat.com> wrote:

Is there any way flush a message queue to get rid of extraneous messages
before using it for the first time?

unlink the message queue filename. Then create it again with new
mq_open() with O_CREAT.

(Or, if scripting or doing it by hand, “rm /dev/mqueue/name” will
do it as well.)

-David

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