Re: TSignalHandler and CINT

From: Fons Rademakers (rdm@pcsalo.cern.ch)
Date: Thu Aug 20 1998 - 01:34:35 MEST


Hi Anthony,

   two things, first you need to inherit a class from TApplication in
which you set the signalhandler. Check the class TRint and make your 
own equivalent.  Second this class cannot be interpreted. The interpreter
can not call virtual functions of classes derived from compiled classes.

So to solve your problem use a modified version of TRint and compile
it with your own main program (for main program example see
$ROOTSYS/include/MAIN_rmain.cxx).

Cheers, Fons.


> 
> Hello
> 
> 	I would like to use signals in a root DAQ macro to allow the macro
> to exit cleanly from its internal loop when a kSigInterrupt is caught.
> 
> 	From a previous roottalk post on this subject I constructed the
> following test...... 
> 
> TDAQInterruptHandler.C 
> {
> 
> //----- Interrupt signal handler
> //_____________________________________________
> class TDAQInterruptHandler : public  TSignalHandler {
> public:
>    TDAQInterruptHandler() :
>       TSignalHandler(7, kFALSE) { fOk = kTRUE; }
> //      TSignalHandler((ESignals)kSigInterrupt, kFALSE) { fOk = kTRUE; }
>    Bool_t  Notify();
>    Bool_t  Ok() { return fOk; }
> public:
>    Bool_t  fOk = kTRUE;
> };
> //_____________________________________________
> Bool_t TDAQInterruptHandler::Notify()
> {
>    Printf("n *** DAQ Break *** keyboard interrupt");
>    fOk = kFALSE;
>    return kTRUE;
> }
> 
> }
> 
> and a test macro loop.C
> 
> Int_t loop(void)
> {
>    gROOT->Reset();
>    gROOT->LoadMacro("TDAQInterruptHandler.C");
>    
>    // Install interrupt handler
>    TDAQInterruptHandler *ih = new TDAQInterruptHandler();
>    gSystem->AddSignalHandler(ih);
>    gROOT->GetApplication->SetSignalHandler(ih);
>    
>    while(ih->Ok());
> 
>    gSystem->RemoveSignalHandler(ih);
> 
>    return 0;
> }
> 
> 
> suffice it to say this isn't working. 
> 
> 	First, what is the correct way to reference enumerated variables,
> such as kSigInterrupt defined in TSysEvtHandler.h, in a macro since cint
> complains if they are included? 
> 
> 	Second, I found that TApplication::SetSignalHandler is protected
> implying that this may be the wrong way to go about this. Can anyone
> recommend a better method?
> 
> 	Thanks for your help.
> 
> ----------------------------------------------------------------------------
> Anthony A. Faust              | Mail me with "PGP" in subject for my pgp key 
> Centre for Subatomic Research | FAX:   403 492 3408
> University of Alberta         | PHONE: 403 492 5017
> Edmonton, Alberta, Canada     | Do not Fold, Spindle, or Mutilate. 
> ----------------------------------------------------------------------------
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



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