#include <TGButton.h>
#include <TInterpreter.h>
+#include <TROOT.h>
#include <unistd.h>
#include <signal.h>
fRunList(0), fAutoRun(0), fStartButt(0), fStopButt(0), fExitButt(0),
fAutoRunTimer(0), fAutoRunScheduled(0), fAutoRunRunning(0),
fRun2PidMap(),
- fTestMode(kFALSE)
+ fTestMode(kFALSE),
+ fDoExit(kFALSE)
{
// Constructor.
// OS Signal handlers
// ROOT's TSignalHAndler works not SIGCHLD ...
AliChildProcTerminator::Instance()->Connect("ChildProcTerm(Int_t,Int_t)", "AliOnlineReco", this, "ChildProcTerm(Int_t,Int_t)");
+
+ // we need this by OnExit() to kill next process child after another
+ Connect("ChildProcTerm(Int_t,Int_t)", "AliOnlineReco", this, "ExitLoopChildProcTerm()");
}
AliOnlineReco::~AliOnlineReco()
if (recMacroPath.IsNull()) {
recMacroPath = "$ALICE_ROOT/MONITOR/rec.C";
}
-
+
s = execlp("alieve",
"alieve",
"-q",
fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED [%d]", run, status), run);
}
fRunList->Layout();
- i->second = 0;
+ fRun2PidMap.erase(i);
if (fAutoRunRunning == run && fAutoRun->IsOn())
{
{
Warning("ChildProcTerm", "Process with pid=%d not registered.", pid);
}
+
+ Emit("ChildProcTerm(Int_t, Int_t)");
+}
+
+void AliOnlineReco::ExitLoopChildProcTerm()
+{
+ if(fDoExit)
+ DoExit();
}
//------------------------------------------------------------------------------
void AliOnlineReco::DoExit()
{
- // Slot called from Exit button.
-
- gSystem->ExitLoop();
+ // Slot called from Exit button or CloseWindow.
+
+ // kill all started processes
+ Int_t pid;
+
+ // disable all widgets & AutoRunTimer
+ // so that user does not initiate other GUI signals
+ if(!fDoExit){
+ fAutoRun->SetEnabled(kFALSE);
+ fStartButt->SetEnabled(kFALSE);
+ fStopButt->SetEnabled(kFALSE);
+ fExitButt->SetEnabled(kFALSE);
+
+ StopAutoRunTimer();
+ fDoExit = kTRUE;
+ gROOT->SetInterrupt(kTRUE);
+ }
+
+ gSystem->ProcessEvents();
+
+ // clear runs std::map
+ for(mIntInt_i i = fRun2PidMap.begin(); i != fRun2PidMap.end(); i++)
+ {
+ pid = i->second;
+
+ if(pid==0)
+ {
+ fRun2PidMap.erase(i); // if process is not started just remove it from map
+ }
+ else
+ {
+ // send kill signal to started process
+ KillPid(pid);
+
+ // we need to exit loop to let ROOT process events list
+ // after kill signal above, process pid starts signal AliChildProcTerminator::ChildProcTerm(int, int)
+ // and arrives in AliOnlineReco::ChildProcTerm(int, int)
+ // after this we return in DoExit() to process next run
+ break;
+ }
+
+ }
+
+ // we can exit after we killed all processes
+ if(fRun2PidMap.empty() ) gSystem->ExitLoop();
}
void AliOnlineReco::CloseWindow()
{
// Virtual method called when window-manager close-window button is pressed.
-
- gSystem->ExitLoop();
+
+ DoExit();
+
}
Int_t AliOnlineReco::RetrieveGRP(UInt_t run, TString &gdc)
class TGCheckButton;
class TGListBox;
+
//______________________________________________________________________________
// Short description of AliOnlineReco
//
public:
AliOnlineReco();
virtual ~AliOnlineReco();
-
+
AliDimIntNotifier* GetSOR(Int_t i) const { return fSOR[i]; }
AliDimIntNotifier* GetEOR(Int_t i) const { return fEOR[i]; }
// Handlers of OS signals.
//------------------------------------------------------------------------------
- void ChildProcTerm(Int_t pid, Int_t status);
+ void ChildProcTerm(Int_t pid, Int_t status); // *SIGNAL*
+ void ExitLoopChildProcTerm();
//------------------------------------------------------------------------------
// Handlers of button signals.
mIntInt_t fRun2PidMap; // Map from run-number to process id.
- Bool_t fTestMode; // Flag for test mode (run xclock instead of alieve).
+ Bool_t fTestMode; // Flag for test mode (run alitestproc instead of alieve).
+ Bool_t fDoExit; // Flag for exit mode
mIntInt_i FindMapEntryByPid(Int_t pid);
TString sqlQuery;
TTimeStamp ts;
sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition REGEXP 'PHYSICS.*'",
- (UInt_t)ts.GetSec()-86400);
+ (UInt_t)ts.GetSec()-86400);
TSQLResult* result = server->Query(sqlQuery);
if (!result)
{
{
for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++)
{
- TSQLRow* row = result->Next();
- TString runStr = row->GetField(0);
- if (runStr.IsDigit())
- win->StartOfRun(runStr.Atoi());
- delete row;
+ TSQLRow* row = result->Next();
+ TString runStr = row->GetField(0);
+ if (runStr.IsDigit())
+ win->StartOfRun(runStr.Atoi());
+ delete row;
}
}
delete result;
}
app.Run(kTRUE);
+
return 0;
}