From: TMA Salome Date: Tue, 10 Apr 2018 14:37:37 +0000 (+0200) Subject: Try X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2Fcleanup_ompi_server;p=modules%2Fkernel.git Try --- diff --git a/bin/addToKillList.py b/bin/addToKillList.py index ca2abd934..7b12eaa98 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -22,8 +22,11 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import os, sys, pickle, signal +import os, sys, pickle, signal, re, time from launchConfigureParser import verbose +import subprocess as sp + +_ompi_server = "ompi-server" ########## adds to the kill list of SALOME one more process ########## @@ -122,7 +125,49 @@ def killList(port=None): os.remove(filedict) pass +def isMatchingKey(pid,keyToFind): + import os + pat=re.compile("[\s]+") + p=sp.Popen(["ps","ocmd",str(pid)],stdout=sp.PIPE) + ret,_=p.communicate() + if p.returncode != 0: + return False + ret=ret.decode("utf-8") + lines=ret.split("\n") + if len(lines) != 3: + return False + res2=pat.split(lines[1]) + if len(res2) != 3: + return False + res2=os.path.basename(res2[-1]) + return res2==keyToFind + +def findZePID(key_to_find): + p=sp.Popen(["pidof",_ompi_server],stdout=sp.PIPE) + ret,_=p.communicate() + assert(p.returncode==0) + ret=ret.decode("utf-8") + pat=re.compile("[\s]+") + pat.split(ret) + pids=[int(elt) for elt in pat.split(ret) if elt!=""] + zePids=[p for p in pids if isMatchingKey(p,key_to_find)] + assert(len(zePids)==1) + return zePids[0] + +def findZePIDWait(key_to_find): + for i in range(10): + try: + time.sleep(0.2) + return findZePID(key_to_find) + except: + pass + assert(False) + if __name__ == "__main__": if verbose(): print sys.argv - addToKillList(sys.argv[1], sys.argv[2]) + if sys.argv[2]!=_ompi_server: + addToKillList(sys.argv[1], sys.argv[2]) + else: + true_pid = findZePIDWait(os.path.basename(sys.argv[3])) + addToKillList(true_pid, sys.argv[2]) pass diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 81ff3e15f..67b19d1cb 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -124,6 +124,9 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer { //wait(NULL); // wait(?) for a child end _pid_mpiServer = pid; + std::stringstream aCommand ; + aCommand << "addToKillList.py " << getpid() << " ompi-server " << urifile.str() << std::ends ; + system(aCommand.str().c_str()); } } #elif defined(MPICH)