On Tue, 18 Jul 2006, Peter W. Draper wrote:
> On Mon, 17 Jul 2006, Mark Taylor wrote:
>
> > The signal trapping is a bit messy though; I've done this in PlasticApp:
> >
> > # Trap signals to perform a tidy shutdown if this hasn't been done
> > # already. This is necessary otherwise we might fail to inform
> > # the hub that we have stopped listening.
> > if {! $trapping_} {
> > set trapping_ 1
> > signal trap * {
> > signal default *
> > puts "signal %S"
> > plastic::PlasticApp::stop_server
> > exit
> > }
> > }
> >
> > i.e. trap all signals and simply exit after cleanup. I feel I ought
> > to be handing back to the default signal handling behaviour after
> > the cleanup code, but I can't see any way to do this.
> > If (a) you know how to or (b) you think the above is sufficiently
> > dangerous/unrespectable that it ought to be modified, then by all
> > means either change it (e.g. reduce list of signals so handled) or
> > discuss further.
>
> Hi Mark,
>
> I've played with these changes as I think that the "*" list is probably
> too encompassing and shouldn't be handling things like FPE, SEGV etc.
> These should be left for the normal handlers (like PRM, core dump
> generators etc.). We should only really be looking at trapping signals
> from the user (kill, control-c), not ones that are generated by
> programming issues (not that I'm guaranteeing bug free code, but that
> should be rare). Anyway I've changed the above to:
>
> if {! $trapping_} {
> set trapping_ 1
> set signals [list SIGHUP SIGINT SIGQUIT SIGTERM]
> signal trap $signals "
> plastic::PlasticApp::stop_server
> puts stderr \"GAIA aborts, signal: %S\"
> exit
> "
> }
>
> which I think are the mostly likely signals.
OK thanks. It would still be beneficial to intercept the behaviour of
SEGV etc so that the hub (which doesn't care why the applications
have terminated, just that they are no longer listening) stays up
to date on who's registered, but given that it seems this can't
(easily) be done without interfering with the signal's normal
behaviour I'm happy to agree that the greater good is served in
these cases by the hub just having to lump it.
Mark
--
Mark Taylor Astronomical Programmer Physics, Bristol University, UK
[log in to unmask] +44-117-928-8776 http://www.star.bris.ac.uk/~mbt/
|