From b3fa8fe11756610daa9c96b69c9e96f5386a4637 Mon Sep 17 00:00:00 2001 From: vuzlov Date: Thu, 17 Sep 2020 19:47:37 +0300 Subject: [PATCH] #16706 fix1. Add check unkill process and new add to KillList --- bin/killSalomeWithPort.py | 36 ++++++++++++++++++++++++++++++++++++ bin/runSalome.py | 16 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 66fd32671..b40bfbe6e 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -243,6 +243,11 @@ def __killMyPort(port, filedict): killpid(int(pid)) except: if verbose(): print(" ------------------ process %s : %s not found"% (pid, cmd[0])) + if int(pid) in checkUnkillProcess(): + try: + killpid(int(pid)) + except: + pass pass pass # for pid ... pass # for process_id ... @@ -394,6 +399,34 @@ def killMyPortSpy(pid, port): killMyPort(port) return +def checkUnkillProcess(): + #check process in system after kill + from salome_utils import getUserName + user = getUserName() + if sys.platform != 'win32': + import subprocess + cmd = "ps -fea | grep 'vsr' | grep -e 'SALOME_' -e 'omniNames' | awk '{print $2}'" % user + prc = subprocess.getoutput(cmd) + if prc: + print("Salome process aren't killed\nCheck this PID: ", prc) + pass + return prc + else: + import subprocess + cmd = 'tasklist /fo csv | findstr /i "SALOME_ omniNames"' + prc = subprocess.getoutput(cmd) + # get only PID + try: + prc = prc.split() + prc = [prc[i].split(',') for i in range(0, len(prc)) if i % 2 == 0] + prc = [int(prc[j][1].replace('"', '')) for j in range(0, len(prc))] + except: + pass + if prc: + print("Salome process aren't killed\nCheck this PID: ", prc) + pass + return prc + if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: ") @@ -410,6 +443,9 @@ if __name__ == "__main__": pass sys.exit(0) pass + elif sys.argv[1] == "--find": + checkUnkillProcess() + sys.exit(0) try: from salomeContextUtils import setOmniOrbUserPath #@UnresolvedImport setOmniOrbUserPath() diff --git a/bin/runSalome.py b/bin/runSalome.py index b4fc7270f..fd9db84a9 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -474,6 +474,7 @@ def startSalome(args, modules_list, modules_root_dir): # clt=orbmodule.client(args) + addToPidict(args) # # Wake up session option @@ -513,6 +514,7 @@ def startSalome(args, modules_list, modules_root_dir): myServer=LoggerServer(args) myServer.run() clt.waitLogger("Logger") + addToPidict(args) # Launch Session Server (to show splash ASAP) # @@ -521,6 +523,7 @@ def startSalome(args, modules_list, modules_root_dir): mySessionServ = SessionServer(args,args['modules'],modules_root_dir) mySessionServ.setpath(modules_list,modules_root_dir) mySessionServ.run() + addToPidict(args) # # Launch Registry Server, @@ -534,6 +537,7 @@ def startSalome(args, modules_list, modules_root_dir): clt.waitNS("/Registry") else: clt.waitNSPID("/Registry",myServer.PID) + addToPidict(args) # # Launch Catalog Server, @@ -549,6 +553,7 @@ def startSalome(args, modules_list, modules_root_dir): clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) else: clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog) + addToPidict(args) # # Launch SalomeDS Server, @@ -564,6 +569,7 @@ def startSalome(args, modules_list, modules_root_dir): clt.waitNS("/Study") else: clt.waitNSPID("/Study",myServer.PID) + addToPidict(args) # # Launch LauncherServer @@ -573,6 +579,7 @@ def startSalome(args, modules_list, modules_root_dir): myCmServer = LauncherServer(args) myCmServer.setpath(modules_list,modules_root_dir) myCmServer.run() + addToPidict(args) # # Launch ConnectionManagerServer @@ -604,6 +611,7 @@ def startSalome(args, modules_list, modules_root_dir): clt.waitNS("/Containers/" + theComputer + "/FactoryServer") else: clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID) + addToPidict(args) if 'pyContainer' in args['standalone']: raise Exception('Python containers no longer supported') @@ -799,6 +807,14 @@ def no_main(): # ----------------------------------------------------------------------------- +def addToPidict(args): + global process_id + from addToKillList import addToKillList + for pid, cmd in list(process_id.items()): + addToKillList(pid, cmd, args['port']) + +# ----------------------------------------------------------------------------- + def main(exeName=None): """Salome launch as a main application""" -- 2.39.2