[Dev] Re: simple daemon dies

Peter Long dev@trilug.org
Thu, 30 May 2002 22:31:04 -0400


----- Original Message -----
From: "Michael Mueller" <mmueller@ss7box.com>
To: <dev@trilug.org>
Sent: Thursday, May 30, 2002 9:09 AM
Subject: Re: [Dev] Re: [Dev] Re: simple daemon dies


> On Thursday 30 May 2002 00:25, Peter Long reputedly wrote:
> <snip> The only signal I am handling is SIGQUIT. I
> > use it to set a flag that causes all the worker threads in my daemon to
> > exit. It works perfectly.
>
> What happens when the the daemon is abruptly killed?   Happy ending with a
> clean restart?
I am not 100% sure what you are asking? When you say "killed abruptly"  do
you mean with SIGKILL(-9)?
In my case the default behaviour (to terminate the process) would abort any
open tcp connections. I would prefer to shut them down gracefully. It
restarts cleanly after being killed.

Looking at man 7 signal it says that the default behaviour for SIGQUIT (-3)
is to terminate and dump core. I do not do that, I just terminate. I guess I
should rather catch SIGTERM (-15) since it can be caught where as SIGKILL
cannot. Its default behaviour is to terminate the process.

> There's one nagging problem I can use some help with.  When I run in
> foreground and get a segmentation fault, there is a nice message alerting
me
> to this event.  When my daemons hit a seg. fault there's no indication in
> /var/log/messages.  Any hints on how to find clues that a daemon did a
seg.
> fault would be most appreciated.

Again according to man 7 signal, SIGSEGV is signaled when a segmentation
fault occurs. I wonder if you could catch it and then try extract some
usefull information from the system. At the very least you could log the
fact that is occured.

--
Peter Long