[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mico-devel
Subject:    RE: way to stop  micod, nsd and evend
From:       Adam Gates <adam.gates () str ! com ! au>
Date:       2000-09-19 1:56:53
[Download RAW message or body]

As has been mentioned before Windows does not have signal handlers.

The better solution (for Windows) would to make the micod, nsd and eventd
into windows services.
Unfortunately this only works on Windows NT and Windows 2000. But services
do have a kind of
signal handler mechanism.

-----Original Message-----
From: Hann Wei Toh [mailto:hannweitoh@yahoo.com]
Sent: Tuesday, 19 September 2000 11:34 AM
To: Multiple recipients of list
Subject: Re: way to stop micod, nsd and evend


--- Matt Moyer <mjm@channelogics.com> wrote:
> I believe that the original question (posed by a
> colleague of mine) was,
> how do you shut down these daemons *gracefully*?  We
> have found in the
> MICO literature that micod can be terminated
> gracefully with a TERM
> signal.  But no such literature exists for nsd or
> eventd.  When we send a
> TERM signal to these processes, they exit without
> closing their TCP
> sockets.  This is annoying when we are testing code
> that uses the daemons
> and we want to restart them every few minutes,
> because the half-open TCP
> connections do not close until the TCP stack times
> out.  We have gotten
> around the problem by using a different port number
> every time we run the
> daemons, but this isn't a very elegant solution.  I
> hope this helps to
> clarify our original question.  So, has anybody
> fugured out a way to shut
> down the nsd or eventd daemons gracefully?

If nsd and eventd are started by micod (the
implementation repository), then sending a TERM signal
to micod will probably shut the two daemons down
gracefully.  I have not done so for quite a while, so
I cannot confirm this at the moment.  Perhaps someone
would like to offer some confirmation.

If the daemons are intended to be run independently
(independent of micod), then their main() method can
be modified a little to add a signal handler.  The
sample code fragment below can be found in
daemon/main.cc (which is part of the micod source
code, I guess).  Having a single statement
"orb->shutdown (TRUE);" in sighandler() is probably
sufficient for simple cases.


void
sighandler (int sig)
{
    if (!CORBA::is_nil (pmd)) {
      pmd->shutdown_server ();
    }
    orb->shutdown (TRUE);
    if (thedb.length() > 0)
	save_imr (thedb.c_str());
    if (!CORBA::is_nil (med))
	CORBA::release (med);
    if (!CORBA::is_nil (pmd))
	CORBA::release (pmd);
    signal (sig, SIG_DFL);
    raise (sig);
}

int main (......)
{
  .....

    signal (SIGTERM, sighandler);
    signal (SIGINT, sighandler);
#ifndef _WINDOWS
    signal (SIGHUP, sighandler);
#endif

    orb->run ();
    // notreached
    return 0;
}


Hann Wei

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic