From 75baf595a14bbc381cccbb3d6c30707019528045 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 8 Jul 2013 14:28:51 +0000 Subject: [PATCH] Fix canceling of Compute() + std::string _genericName; --- src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx | 20 +++++++++----------- src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx | 3 ++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index 76629fa..e2e07f8 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -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 } diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx index 7ac6009..232c16e 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx @@ -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: -- 2.39.2