Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/base/inc/LinkDef2.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
#pragma link C++ class TStringToken;
#pragma link C++ class TSubString;
#pragma link C++ class TSysEvtHandler;
#pragma link C++ class TSigHandling+;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you preferred TSigHandling over TSigHandler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There exists TSignalHandler (https://github.com/root-project/root/blob/8f66431755137822f726c4594b680997324439b5/core/base/inc/TSysEvtHandler.h). I feel TSigHandler is so close to TSignalHandler that it could be difficult to distinguish.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find this very confusing. What is the difference between the two?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason which brought you to create a dictionary for the class(es)?

#pragma link C++ class TSystem+;
#pragma link C++ class TSystemFile+;
#pragma link C++ class TSystemDirectory+;
Expand Down
93 changes: 93 additions & 0 deletions core/base/inc/TSigHandling.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// @(#)root/base:$Id$
// Author: Fons Rademakers 15/09/95
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to your name and current month


/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#ifndef ROOT_TSigHandling
#define ROOT_TSigHandling


//////////////////////////////////////////////////////////////////////////
// //
// TSigHandling //
// //
// Abstract base class defining a generic interface to the underlying //
// Operating System. //
// //
//////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#ifndef WIN32
#include <unistd.h>
#endif

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TInetAddress
#include "TInetAddress.h"
#endif
#ifndef ROOT_TTimer
#include "TTimer.h"
#endif
#ifndef ROOT_ThreadLocalStorage
#include "ThreadLocalStorage.h"
#endif

class TSeqCollection;
class TFdSet;
class TVirtualMutex;

#ifdef __CINT__
typedef void *Func_t;
#else
typedef void ((*Func_t)());
#endif

R__EXTERN const char *gRootDir;
R__EXTERN TVirtualMutex *gSystemMutex;

class TSigHandling : public TNamed {

protected:
TFdSet *fSignals; //!Signals that were trapped
Int_t fSigcnt; //Number of pending signals
TSeqCollection *fSignalHandler; //List of signal handlers

public:
TSigHandling(const char *name = "Generic", const char *title = "Generic Signal Handling");
virtual ~TSigHandling();

//---- Misc
virtual void Init();
virtual void StackTrace();

//---- Handling of system signals
virtual Bool_t HaveTrappedSignal(Bool_t pendingOnly);
virtual void DispatchSignals(ESignals sig);
virtual void AddSignalHandler(TSignalHandler *sh);
virtual TSignalHandler *RemoveSignalHandler(TSignalHandler *sh);
virtual void ResetSignal(ESignals sig, Bool_t reset = kTRUE);
virtual void ResetSignals();
virtual void IgnoreSignal(ESignals sig, Bool_t ignore = kTRUE);
virtual void IgnoreInterrupt(Bool_t ignore = kTRUE);
virtual TSeqCollection *GetListOfSignalHandlers();
virtual void SigAlarmInterruptsSyscalls(Bool_t) { }

ClassDef(TSigHandling,0)
};

R__EXTERN TSigHandling *gSigHandling;

#endif
5 changes: 1 addition & 4 deletions core/base/inc/TSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,9 @@ class TSystem : public TNamed {
TFdSet *fWritemask; //!Files that should be checked for write events
TFdSet *fReadready; //!Files with reads waiting
TFdSet *fWriteready; //!Files with writes waiting
TFdSet *fSignals; //!Signals that were trapped
Int_t fNfd; //Number of fd's in masks
Int_t fMaxrfd; //Largest fd in read mask
Int_t fMaxwfd; //Largest fd in write mask
Int_t fSigcnt; //Number of pending signals
TString fWdpath; //Working directory
TString fHostname; //Hostname
Bool_t fInsideNotify; //Used by DispatchTimers()
Expand All @@ -284,7 +282,6 @@ class TSystem : public TNamed {
Int_t fLevel; //Level of nested eventloops

TSeqCollection *fTimers; //List of timers
TSeqCollection *fSignalHandler; //List of signal handlers
TSeqCollection *fFileHandler; //List of file handlers
TSeqCollection *fStdExceptionHandler; //List of std::exception handlers
TSeqCollection *fOnExitList; //List of items to be cleaned-up on exit
Expand Down Expand Up @@ -368,7 +365,7 @@ class TSystem : public TNamed {
virtual void ResetSignals();
virtual void IgnoreSignal(ESignals sig, Bool_t ignore = kTRUE);
virtual void IgnoreInterrupt(Bool_t ignore = kTRUE);
virtual TSeqCollection *GetListOfSignalHandlers() const { return fSignalHandler; }
virtual TSeqCollection *GetListOfSignalHandlers();
virtual void AddFileHandler(TFileHandler *fh);
virtual TFileHandler *RemoveFileHandler(TFileHandler *fh);
virtual TSeqCollection *GetListOfFileHandlers() const { return fFileHandler; }
Expand Down
2 changes: 2 additions & 0 deletions core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ namespace std {} using namespace std;
#include "TUrl.h"
#else
#include "TUnixSystem.h"
#include "TUnixSigHandling.h"
#endif
#elif defined(R__WIN32)
#include "TWinNTSystem.h"
Expand Down Expand Up @@ -1690,6 +1691,7 @@ void TROOT::InitSystem()
gSystem = new TMacOSXSystem;
#else
gSystem = new TUnixSystem;
gSigHandling = new TUnixSigHandling;
#endif
#elif defined(R__WIN32)
gSystem = new TWinNTSystem;
Expand Down
171 changes: 171 additions & 0 deletions core/base/src/TSigHandling.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// @(#)root/base:$Id: 8944840ba34631ec28efc779647618db43c0eee5 $
// Author: Fons Rademakers 15/09/95

/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

/** \class TSystem

Abstract base class defining a generic interface to the underlying
Operating System.
This is not an ABC in the strict sense of the (C++) word. For
every member function there is an implementation (often not more
than a call to AbstractMethod() which prints a warning saying
that the method should be overridden in a derived class), which
allows a simple partial implementation for new OS'es.
*/

#ifdef WIN32
#include <io.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include <algorithm>
#include <sys/stat.h>

#include "Riostream.h"
#include "TSystem.h"
#include "TSigHandling.h"
#include "TApplication.h"
#include "TException.h"
#include "TROOT.h"
#include "TClass.h"
#include "TClassTable.h"
#include "TEnv.h"
#include "TBrowser.h"
#include "TString.h"
#include "TOrdCollection.h"
#include "TInterpreter.h"
#include "TRegexp.h"
#include "TTimer.h"
#include "TObjString.h"
#include "TError.h"
#include "TPluginManager.h"
#include "TUrl.h"
#include "TVirtualMutex.h"
#include "compiledata.h"
#include "RConfigure.h"

TSigHandling *gSigHandling = 0;

ClassImp(TSigHandling)

////////////////////////////////////////////////////////////////////////////////
/// Create a new OS interface.

TSigHandling::TSigHandling(const char *name, const char *title) : TNamed(name, title)
{
fSignals = 0;
fSigcnt = 0;
}

////////////////////////////////////////////////////////////////////////////////
/// Delete the OS interface.

TSigHandling::~TSigHandling()
{
if (fSignalHandler) {
fSignalHandler->Delete();
SafeDelete(fSignalHandler);
}
}

////////////////////////////////////////////////////////////////////////////////
/// Init the OS interface.
void TSigHandling::Init()
{
fSignalHandler = new TOrdCollection;
}

////////////////////////////////////////////////////////////////////////////////
/// Add a signal handler to list of system signal handlers. Only adds
/// the handler if it is not already in the list of signal handlers.

Bool_t TSigHandling::HaveTrappedSignal(Bool_t)
{
AbstractMethod("HaveTrappedSignal");
return kFALSE;
}

////////////////////////////////////////////////////////////////////////////////
/// Dispatch signals.

void TSigHandling::DispatchSignals(ESignals /*sig*/)
{
AbstractMethod("DispatchSignals");
}


////////////////////////////////////////////////////////////////////////////////
/// Add a signal handler to list of system signal handlers. Only adds
/// the handler if it is not already in the list of signal handlers.

void TSigHandling::AddSignalHandler(TSignalHandler *)
{
AbstractMethod("AddSignalHandler");
}

////////////////////////////////////////////////////////////////////////////////
/// Remove a signal handler from list of signal handlers. Returns
/// the handler or 0 if the handler was not in the list of signal handlers.

TSignalHandler *TSigHandling::RemoveSignalHandler(TSignalHandler *)
{
AbstractMethod("RemoveSignalHandler");
return 0;
}

////////////////////////////////////////////////////////////////////////////////
/// If reset is true reset the signal handler for the specified signal
/// to the default handler, else restore previous behaviour.

void TSigHandling::ResetSignal(ESignals /*sig*/, Bool_t /*reset*/)
{
AbstractMethod("ResetSignal");
}

////////////////////////////////////////////////////////////////////////////////
/// Reset signals handlers to previous behaviour.

void TSigHandling::ResetSignals()
{
AbstractMethod("ResetSignals");
}

////////////////////////////////////////////////////////////////////////////////
/// If ignore is true ignore the specified signal, else restore previous
/// behaviour.

void TSigHandling::IgnoreSignal(ESignals /*sig*/, Bool_t /*ignore*/)
{
AbstractMethod("IgnoreSignal");
}

////////////////////////////////////////////////////////////////////////////////
/// If ignore is true ignore the interrupt signal, else restore previous
/// behaviour. Typically call ignore interrupt before writing to disk.

void TSigHandling::IgnoreInterrupt(Bool_t ignore)
{
IgnoreSignal(kSigInterrupt, ignore);
}

////////////////////////////////////////////////////////////////////////////////
/// Obtain the current signal handlers
TSeqCollection *TSigHandling::GetListOfSignalHandlers()
{
return fSignalHandler;
}

////////////////////////////////////////////////////////////////////////////////
/// Print a stack trace.

void TSigHandling::StackTrace()
{
AbstractMethod("StackTrace");
}
Loading