My application (on QNX 4.24) uses POSIX message queues. I want my
application to ensure that the Mqueue server is running before it
starts trying to use msg queues.
I can just blindly spawn Mqueue at any time. However if Mqueue is
already running, I get a console message from qnx_prefix_attach that
it already exists. I’d rather not have the user get confused by that
message if I can avoid it.
I would like to see if I need to spawn Mqueue. What is the best way to
find out if Mqueue is already running?
Apparently qnx_name_locate doesn’t work (because Mqueue’s name is not
attached?). I see that “sin na” doesn’t show Mqueue.
I could spawn a command like “sin | grep Mqueue > temp.txt” and then
check the size of the output file. That seems pretty cumbersome. Also,
my application runs with root privileges (which is needs to start
Mqueue, among other reasons), and currently on my system a root
process can’t create a new file in my application’s directory(?).
Thanks
Paul McGlynn <pmcglynn@broadcom.com> wrote:
My application (on QNX 4.24) uses POSIX message queues. I want my
application to ensure that the Mqueue server is running before it
starts trying to use msg queues.
I can just blindly spawn Mqueue at any time. However if Mqueue is
already running, I get a console message from qnx_prefix_attach that
it already exists. I’d rather not have the user get confused by that
message if I can avoid it.
I would like to see if I need to spawn Mqueue. What is the best way to
find out if Mqueue is already running?
Try a stat() on /dev/mqueue. When Mqueue is up and running, it will
create that directory. If you can successfully stat the directory,
Mqueue is running and ready to handle requests.
Apparently qnx_name_locate doesn’t work (because Mqueue’s name is not
attached?). I see that “sin na” doesn’t show Mqueue.
No, Mqueue isn’t located with qnx_name_locate(), it is an I/O manager,
so it is located with an open() of some flavour – usually mq_open().
Also,
my application runs with root privileges (which is needs to start
Mqueue, among other reasons), and currently on my system a root
process can’t create a new file in my application’s directory(?).
That seems odd. When you try to create a file in the directory,
what errno is set? That is, if you do open(…, O_CREAT, …) what
does open() return, and what is errno set to?
-David
How about checking for the presence of “/dev/mqueue”, maybe using
ccess( “/dev/mqueue”, R_OK).
ms…
Paul McGlynn <pmcglynn@broadcom.com> wrote in message
news:3a23e2f3.97459068@inn.qnx.com…
My application (on QNX 4.24) uses POSIX message queues. I want my
application to ensure that the Mqueue server is running before it
starts trying to use msg queues.
I can just blindly spawn Mqueue at any time. However if Mqueue is
already running, I get a console message from qnx_prefix_attach that
it already exists. I’d rather not have the user get confused by that
message if I can avoid it.
I would like to see if I need to spawn Mqueue. What is the best way to
find out if Mqueue is already running?
Apparently qnx_name_locate doesn’t work (because Mqueue’s name is not
attached?). I see that “sin na” doesn’t show Mqueue.
I could spawn a command like “sin | grep Mqueue > temp.txt” and then
check the size of the output file. That seems pretty cumbersome. Also,
my application runs with root privileges (which is needs to start
Mqueue, among other reasons), and currently on my system a root
process can’t create a new file in my application’s directory(?).
Thanks
Make that access().
Mike Schneider <Mike.Schneider@us.heidelberg.com> wrote in message
news:900sng$8ke$1@inn.qnx.com…
How about checking for the presence of “/dev/mqueue”, maybe using
ccess( “/dev/mqueue”, R_OK).
ms…