Salome HOME
Fix canceling of Compute()
authoreap <eap@opencascade.com>
Mon, 8 Jul 2013 14:28:51 +0000 (14:28 +0000)
committereap <eap@opencascade.com>
Mon, 8 Jul 2013 14:28:51 +0000 (14:28 +0000)
+  std::string                     _genericName;

src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx

index 76629fa055851e50dd8b946edba74175447097b5..e2e07f879bb008fec14f560a751b9c5bd014c00d 100644 (file)
@@ -3258,8 +3258,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   // a unique working file name
   // to avoid access to the same files by eg different users
-  TCollection_AsciiString aGenericName
-    = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
+  _genericName = GHS3DPlugin_Hypothesis::GetFileName(_hyp);
+  TCollection_AsciiString aGenericName((char*) _genericName.c_str() );
 
   TCollection_AsciiString aResultFileName;
   TCollection_AsciiString aLogFileName    = aGenericName + ".log";    // log
@@ -3403,7 +3403,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   // run ghs3d mesher
   // -----------------
 
-  TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
+  TCollection_AsciiString cmd(char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
   cmd += TCollection_AsciiString(" -f ") + aGenericName;  // file to read
   cmd += TCollection_AsciiString(" 1>" ) + aLogFileName;  // dump into file
   // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
@@ -3533,8 +3533,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   // a unique working file name
   // to avoid access to the same files by eg different users
-  TCollection_AsciiString aGenericName
-    = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
+  _genericName = GHS3DPlugin_Hypothesis::GetFileName(_hyp);
+  TCollection_AsciiString aGenericName((char*) _genericName.c_str() );
   TCollection_AsciiString aGenericNameRequired = aGenericName + "_required";
 
   TCollection_AsciiString aLogFileName    = aGenericName + ".log";    // log
@@ -3749,12 +3749,10 @@ void GHS3DPlugin_GHS3D::CancelCompute()
   _compute_canceled = true;
 #ifdef WNT
 #else
-  TCollection_AsciiString aGenericName
-    = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
-  TCollection_AsciiString cmd =
-    TCollection_AsciiString("ps ux | grep ") + aGenericName;
-  cmd += TCollection_AsciiString(" | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1");
-  system( cmd.ToCString() );
+  std::string cmd = "ps xo pid,args | grep " + _genericName;
+  cmd += " | grep -e \"^ *[0-9]\\+ \\+" + GHS3DPlugin_Hypothesis::GetExeName() + "\"";
+  cmd += " | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1";
+  system( cmd.c_str() );
 #endif
 }
 
index 7ac6009c3a91396b9e48237fa06428de992fe2cf..232c16e7681b233d0b95af43e64810496bd4c245 100644 (file)
@@ -82,8 +82,9 @@ public:
   static const char* Name() { return "GHS3D_3D"; }
 
 protected:
-  const GHS3DPlugin_Hypothesis* _hyp;
+  const GHS3DPlugin_Hypothesis*   _hyp;
   const StdMeshers_ViscousLayers* _viscousLayersHyp;
+  std::string                     _genericName;
    
 private: