Print

Print


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.

Cheers,

Peter.