Skip to content
Draft
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 TSignalManager+;
Copy link
Member

Choose a reason for hiding this comment

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

Please amend the original commit instead of adding it with one name and then renaming.

#pragma link C++ class TSystem+;
#pragma link C++ class TSystemFile+;
#pragma link C++ class TSystemDirectory+;
Expand Down
75 changes: 75 additions & 0 deletions core/base/inc/TSignalManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// @(#)root/base:$Id$
// 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. *
*************************************************************************/

#ifndef ROOT_TSignalManager
#define ROOT_TSignalManager


//////////////////////////////////////////////////////////////////////////
// //
// TSignalManager //
// //
// 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

#include "TInetAddress.h"
#include "TNamed.h"
#include "ThreadLocalStorage.h"
#include "TString.h"
#include "TTimer.h"

class TSeqCollection;
class TFdSet;

typedef void ((*Func_t)());

class TSignalManager : public TNamed {

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

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

//---- 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(TSignalManager,0)
};

R__EXTERN TSignalManager *gSignalManager;

#endif
5 changes: 1 addition & 4 deletions core/base/inc/TSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,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 @@ -274,7 +272,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 @@ -358,7 +355,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
6 changes: 6 additions & 0 deletions core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ namespace std {} using namespace std;
#if defined(R__UNIX)
#if defined(R__HAS_COCOA)
#include "TMacOSXSystem.h"
#include "TUnixSignalManager.h"
#include "TUrl.h"
#else
#include "TUnixSystem.h"
#include "TUnixSignalManager.h"
#endif
#elif defined(R__WIN32)
#include "TWinNTSystem.h"
Expand Down Expand Up @@ -1849,13 +1851,17 @@ void TROOT::InitSystem()
if (gSystem == 0) {
#if defined(R__UNIX)
#if defined(R__HAS_COCOA)
gSignalManager = new TUnixSignalManager;
gSystem = new TMacOSXSystem;
#else
gSignalManager = new TUnixSignalManager;
gSystem = new TUnixSystem;
#endif
#elif defined(R__WIN32)
gSignalManager = new TUnixSignalManager;
gSystem = new TWinNTSystem;
#else
gSignalManager = new TSignalManager;
gSystem = new TSystem;
#endif

Expand Down
171 changes: 171 additions & 0 deletions core/base/src/TSignalManager.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 "TSignalManager.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"

TSignalManager *gSignalManager = 0;

ClassImp(TSignalManager)

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

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

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

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

////////////////////////////////////////////////////////////////////////////////
/// Init the OS interface.
void TSignalManager::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 TSignalManager::HaveTrappedSignal(Bool_t)
{
AbstractMethod("HaveTrappedSignal");
return kFALSE;
}

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

void TSignalManager::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 TSignalManager::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 *TSignalManager::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 TSignalManager::ResetSignal(ESignals /*sig*/, Bool_t /*reset*/)
{
AbstractMethod("ResetSignal");
}

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

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

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

void TSignalManager::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 TSignalManager::IgnoreInterrupt(Bool_t ignore)
{
IgnoreSignal(kSigInterrupt, ignore);
}

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

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

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