]> SALOME platform Git repositories - modules/kernel.git/blobdiff - bin/addToKillList.py
Salome HOME
A service to generate artificialy SIGSEGV to test robustness of high level layers
[modules/kernel.git] / bin / addToKillList.py
index ca31fface9fc43522a41a03a4e1f88ff1bfdc5e9..840763306d6ef3f6f220cc9792d0956cf4ca08bd 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/env python3
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -55,7 +55,7 @@ def addToKillList(command_pid, command, port=None):
     try:
         with open(filedict, 'rb') as fpid:
             process_ids=pickle.load(fpid)
-    except:
+    except Exception:
         process_ids=[]
         pass
     # check if PID is already in dictionary
@@ -78,10 +78,12 @@ def addToKillList(command_pid, command, port=None):
             if verbose(): print("addToKillList: %s : %s" % ( str(command_pid), command ))
             process_ids.append({int(command_pid): [command]})
             dir = os.path.dirname(filedict)
-            if not os.path.exists(dir): os.makedirs(dir, 0o777)
+            if not os.path.exists(dir):
+                from salome_utils import makeDir
+                makeDir(dir)
             with open(filedict,'wb') as fpid:
                 pickle.dump(process_ids, fpid)
-        except:
+        except Exception:
             if verbose(): print("addToKillList: can not add command %s : %s to the kill list" % ( str(command_pid), command ))
             pass
         pass
@@ -105,7 +107,7 @@ def killList(port=None):
     try:
         with open(filedict, 'rb') as fpid:
             process_ids=pickle.load(fpid)
-    except:
+    except Exception:
         process_ids=[]
         pass
     # kill processes
@@ -114,13 +116,14 @@ def killList(port=None):
         for pid, cmd in list(process_id.items()):
             try:
                 os.kill(int(pid),signal.SIGKILL)
-            except:
+            except Exception:
                 print("  ------------------ process %s : %s inexistant"% (pid, cmd[0]))
                 pass
             pass
         pass
     # remove processes dictionary file
-    os.remove(filedict)
+    if os.path.exists(filedict):
+        os.remove(filedict)
     pass
 
 if __name__ == "__main__":