1 #include "StCloseFileOnTerminate.h"
5 #include "TApplication.h"
10 StCloseFileOnTerminate:: StCloseFileOnTerminate() : TSignalHandler(kSigTermination, kFALSE)
18 if (! fgCloseFileOnTerminate ) {
20 ::Warning(
"StCloseFileOnTerminate::Instantiate",
"Asynch signal handler has been created");
22 return *fgCloseFileOnTerminate;
28 Error(__FUNCTION__,
" Closing all TFiles . . . . ");
29 TSeqCollection *files = gROOT->GetListOfFiles();
31 if (files && files->GetSize() >0 ) {
33 while( TFile *f = (TFile *) next() ) {
34 if ( f-> IsWritable() ) {
35 Error(__FUNCTION__,
"file %s will be closed", f->GetName());
38 Error(__FUNCTION__,
"file %s has been closed", f->GetName());
43 if (count)
Error(__FUNCTION__,
"%d files have been closed", count);
44 else Print(
" There was no open file to close");
46 Error(__FUNCTION__,
"Close any files or sockets before emptying CINT . . . . ");
49 Error(__FUNCTION__,
"Terminating . . . . ");
50 gApplication->Terminate(15);
54 StTerminateNotified::StTerminateNotified() : fTerminateHandler()
61 StTerminateNotified::~StTerminateNotified()
63 fTerminateHandler->DeActivate();
67 delete fTerminateHandler; fTerminateHandler = 0;
73 fNotificator.SetNotifiedCallBack();
74 Error(__FUNCTION__,
" Job will be terminated soon by the external signal . . . . ");
Class StCloseFileOnTerminate - it is a singleton to catch the SIGTERM signal (sent by Condor for exam...
virtual Bool_t Notify()
Close the open ROOT files upon SIGTERM sent by system to terminate the job.
virtual Bool_t Notify()
Close the open ROOT files upon SIGTERM sent by system to terminate the job.
static StCloseFileOnTerminate & Instantiate()
Create an instance of the signal handler (Should be called at once by code)