How to receive signals in Resource manager?

bridged with qdn.public.qnxrtp.applications
Post Reply
Chris Rose

How to receive signals in Resource manager?

Post by Chris Rose » Mon Aug 12, 2002 5:40 pm

I have a resource manager and I would like to have a signal that tells it to
reinitialize itself. What function to I have to override to receive signal?
Which signal would make sense to use? SIGHUP maybe?

David Gibbs

Re: How to receive signals in Resource manager?

Post by David Gibbs » Wed Aug 14, 2002 4:33 pm

Chris Rose <rose_chris@excite.com> wrote:
I have a resource manager and I would like to have a signal that tells it to
reinitialize itself. What function to I have to override to receive signal?
There aren't any callbacks for handling signals.

But if you take a look at cvs.qnx.com, you can see that dispatch_block()
will return NULL if the MsgReceive is interrupted by a signal.

So, you could just attach a signal handler, (sigaction()) and handle
the signal and also check dispatch_block() for a NULL return.

Of course, this does give the issue of what happens if the signal hits
while you're not in dispatch_block() and all the messiness with that.

If you're using a threadpool, this is messier, I'm not sure what to
do for that.

So, what I'd do:

-- create a thread to handle signals; probably use sigwaitinfo() to block
waiting for the signals in it
-- when the signal is received, send a re-init pulse to your resmgr
channel (message_connect() will get you a connection to your resmgr
channel)
-- mask all signals in your main thread, the one that is going to go
into you dispatch_block() loop (or the one that will start the thread
pool, since signal mask will be inherited by the thread pool threads)
-- attach a pulse handler for your re-initialize pule (this is done to
"reserve" that pulse for your re-init, so it doesn't get allocated for
something else)
-- put code between the dispatch_block() and dispatch_handle() call to
check for your re-init pulse, and if received, to re-init; i.e. break
out of your dispatch loop, do the appropriate re-init, and re-start the
dispatch loop
Which signal would make sense to use? SIGHUP maybe?
SIGHUP has traditionally been used in (some) Unixes as a "re-init"
option. But, they didn't have lots of spare signals to choose from.
Since you have a set of signals without pre-defined meaning in SIGRTMIN
through SIGRTMAX, I'd choose one of those, rather than overloading SIGHUP.

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

Post Reply

Return to “qdn.public.qnxrtp.applications”