3 # Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
4 # PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 import os, sys, pickle, string, signal
24 ########## adds to the kill list of SALOME one more process ##########
27 if os.environ.has_key('NSPORT'):
28 my_port = os.environ['NSPORT']
33 file = open(os.environ["OMNIORB_CONFIG"], "r")
36 l = string.split(s, ":")
37 if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" :
38 my_port = int(l[len(l)-1])
46 print "myport = ", my_port
49 def addToKillList(command_pid, command):
50 my_port = findFileDict()
51 from killSalomeWithPort import getPiDict
52 filedict=getPiDict(my_port)
54 fpid=open(filedict, 'r')
55 process_ids=pickle.load(fpid)
62 for process_id in process_ids:
64 for pid, cmd in process_id.items():
65 #print "see process %s : %s"% (pid, cmd[0])
66 if pid == command_pid:
72 command=(command.split(" "))[0]
75 process_ids.append({command_pid: [command]})
76 fpid=open(filedict,'w')
77 pickle.dump(process_ids, fpid)
80 print "addToKillList: can not add command %s to the kill list"% filedict
86 my_port = findFileDict()
87 from killSalomeWithPort import getPiDict
88 filedict=getPiDict(my_port)
90 fpid=open(filedict, 'r')
91 process_ids=pickle.load(fpid)
97 for process_id in process_ids:
99 for pid, cmd in process_id.items():
100 print "stop process %s : %s"% (pid, cmd[0])
102 os.kill(int(pid),signal.SIGKILL)
104 print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
113 if __name__ == "__main__":
115 addToKillList(sys.argv[1], sys.argv[2])