Re: [ROOT] Receiving Signals from other applications

From: Fons Rademakers (
Date: Wed Jan 21 2004 - 16:29:14 MET

Hi Micheal,

  to register handlers for any signals do like this (example for
handling SIGUSR1):

class AliMDCInterruptHandler : public TSignalHandler {
   AliMDC *fMDC;   // alimdc to signal
   AliMDCInterruptHandler(AliMDC *mdc) 
               : TSignalHandler(kSigUser1, kFALSE), fMDC(mdc) { }
   Bool_t Notify() {
      Info("Notify", "received a SIGUSR1 signal");
      return kTRUE;

Next register this handler in your application like this:

   // install SIGUSR1 handler to allow clean interrupts
   gSystem->AddSignalHandler(new AliMDCInterruptHandler(this));

where "this" is an AliMDC object.

This is quite simple and does not require any static functions (see the
calling of fMDC->StopLoop().

Cheers, Fons.

On Mon, 2004-01-19 at 16:10, Michael T. Gericke wrote:
> Hi,
> I am writing a compiled program using ROOT.
> I have the following problem:
> I need to be able to receive a standard signal
> such as "SIGUSR" as defined in signal.h, from
> another application and respond to it.
> Now, the function that handles the signal in the
> ROOT program needs to be a static class member
> (as far as I can tell that's the only way it works
> using signal.h).
> I have made the function a static member of my
> program's main frame (TGMainFrame class).
> However, I can not call any of the other member 
> functions (which I need to be able to do) because, 
> well..., the static member function doesn't have 
> access to those.
> My questions are:
> 1) Did you guys build in a nicer way to handle
>    messages from other applications? 
> 2) If not, is there a way to get access to the
>    mainframe object from a static member function
>    the mainframe class?
> Thanks,
> Michael
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail:              Phone: +41 22 7679248
WWW:      Fax:   +41 22 7679480

This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET