]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Major change:
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Feb 2012 10:15:24 +0000 (10:15 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Feb 2012 10:15:24 +0000 (10:15 +0000)
   - Fix AliOnlineReco.h exit (useful for alionlinemonitor)
     Problem:
           the user must select each started process from AliOnlineReco and than click Stop button before clicking on Exit (or closing window from x button). If by mistake he does not do this in this exact way, child processes become zombies.
      Fix: clicking on Exit button or X window button will exit AliOnlineReco (and kill all started processes) without needing to select and stop each process.

minor changes:
   - Fix a few comments, indentations & look of code

Mihai

MONITOR/AliOnlineReco.cxx
MONITOR/AliOnlineReco.h
MONITOR/alionlinemonitor.cxx
MONITOR/alitestproc.cxx
MONITOR/rec.C

index 7af05a9325913caaca5293e40606c469aded400a..80498331460dacf3a53794f95c205f94eb44fe64 100644 (file)
@@ -19,6 +19,7 @@
 #include <TGButton.h>
 
 #include <TInterpreter.h>
+#include <TROOT.h>
 
 #include <unistd.h>
 #include <signal.h>
@@ -35,7 +36,8 @@ AliOnlineReco::AliOnlineReco() :
   fRunList(0), fAutoRun(0), fStartButt(0), fStopButt(0), fExitButt(0),
   fAutoRunTimer(0), fAutoRunScheduled(0), fAutoRunRunning(0),
   fRun2PidMap(),
-  fTestMode(kFALSE)
+  fTestMode(kFALSE),
+  fDoExit(kFALSE)
 {
   // Constructor.
 
@@ -92,6 +94,9 @@ AliOnlineReco::AliOnlineReco() :
   // 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()
@@ -223,7 +228,7 @@ void AliOnlineReco::StartAliEve(mIntInt_i& mi)
         if (recMacroPath.IsNull()) {
           recMacroPath = "$ALICE_ROOT/MONITOR/rec.C";
         }
-
+        
         s = execlp("alieve",
              "alieve",
              "-q",
@@ -387,7 +392,7 @@ void AliOnlineReco::ChildProcTerm(Int_t pid, Int_t status)
       fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED [%d]", run, status), run);
     }
     fRunList->Layout();
-    i->second = 0;
+    fRun2PidMap.erase(i);
 
     if (fAutoRunRunning == run && fAutoRun->IsOn())
     {
@@ -403,6 +408,14 @@ void AliOnlineReco::ChildProcTerm(Int_t pid, Int_t status)
   {
     Warning("ChildProcTerm", "Process with pid=%d not registered.", pid);
   }
+  Emit("ChildProcTerm(Int_t, Int_t)");
+}
+
+void AliOnlineReco::ExitLoopChildProcTerm()
+{
+  if(fDoExit)
+    DoExit();
 }
 
 //------------------------------------------------------------------------------
@@ -463,16 +476,59 @@ void AliOnlineReco::DoStop()
 
 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)
index d668584be048e7aa49ee790414015b745a7aadf3..d20eec29e9f2188d73b5a42e6c5ffe177e44dd16 100644 (file)
@@ -24,6 +24,7 @@ class TGTextButton;
 class TGCheckButton;
 class TGListBox;
 
+
 //______________________________________________________________________________
 // Short description of AliOnlineReco
 //
@@ -34,7 +35,7 @@ class AliOnlineReco : public TGMainFrame
 public:
   AliOnlineReco();
   virtual ~AliOnlineReco();
-
+  
   AliDimIntNotifier* GetSOR(Int_t i) const { return fSOR[i]; }
   AliDimIntNotifier* GetEOR(Int_t i) const { return fEOR[i]; }
 
@@ -56,7 +57,8 @@ public:
   // 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.
@@ -100,7 +102,8 @@ private:
 
   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);
 
index 1c7c5118e51d4067fff7c0c9137bf57c3e651851..5f1c401367cb0692759bae001e5b7f9d029c81d1 100644 (file)
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
     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)
     {
@@ -104,16 +104,17 @@ int main(int argc, char **argv)
     {
       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;
 }
index bdbb255484bfe74d53346aa6a845ad01a34b5230..12f016f16f9da40ca98fbaa43798b6fc1dad8555 100644 (file)
@@ -18,5 +18,7 @@ int main(int argc, char **argv)
   mf->MapWindow();
 
   app.Run(kTRUE);
+  
+  app.Terminate(0);
   return 0;
 }
index 30aa99c887d7f5d031b081cbfc1f99dfdc5d8c7e..fc2211e4af70281c3787c120fe8d8f0df33cbbff 100644 (file)
@@ -19,7 +19,8 @@ void rec(const char *filename="raw.root")
   AliReconstruction rec;
 
   // QA options
-  rec.SetRunQA(":") ;
+  
+  rec.SetRunQA(":");
   rec.SetRunGlobalQA(kFALSE);
   rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
   rec.SetRunPlaneEff(kTRUE);