How to use TSignalHandler

From: Cyril Broude (Cyril.Broude@Physik.uni-muenchen.de)
Date: Wed Oct 29 1997 - 16:45:57 MET


Dear RootTalk

 I am trying to trap SIGTERM using a class I derive from TSignalHandler.
I assumed it would be very much like what I've done succesfully with
TTimer.

Immediately after the instance is created, I get the following message:

SysError in <UnixSignal>: sigaction (Success)


My code is:

/////////////////////////////////////////////
#include "TSystem.h"
#include "TSysEvtHandler.h"
#include <signal.h>
class SignalTrap: public TSignalHandler
{
  private:
    ESignals signal;

  public:
    SignalTrap(ESignals sig);
    Bool_t Notify();
    ESignals GetMySignal()
    {
      return(signal);
    }
};

SignalTrap::SignalTrap(ESignals sig): TSignalHandler(sig)
{
  signal=sig;
  gSystem->AddSignalHandler(this);
}

Bool_t SignalTrap::Notify()
{
  printf("trapped a signal\n");
  return kTRUE;
}
//////////////////////////////////////

and I instantiate with:

  SignalTrap *sigtrap = new SignalTrap((ESignals)SIGTERM);

Calls to GetMySignal and GetSignal return 15, as expected. Sending
kill or kill -s 15 to the process, I dont see that Notify() has been
entered.

Regards,

Cyril



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET