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
23 from launchConfigureParser import verbose
25 ########## adds to the kill list of SALOME one more process ##########
28 if os.environ.has_key('NSPORT'):
29 my_port = os.environ['NSPORT']
34 file = open(os.environ["OMNIORB_CONFIG"], "r")
37 l = string.split(s, ":")
38 if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" :
39 my_port = int(l[len(l)-1])
47 if verbose(): print "myport = ", my_port
50 def addToKillList(command_pid, command):
51 my_port = findFileDict()
52 from killSalomeWithPort import getPiDict
53 filedict=getPiDict(my_port)
55 fpid=open(filedict, 'r')
56 process_ids=pickle.load(fpid)
63 for process_id in process_ids:
64 if verbose(): print process_id
65 for pid, cmd in process_id.items():
66 #print "see process %s : %s"% (pid, cmd[0])
67 if pid == command_pid:
73 command=(command.split(" "))[0]
76 process_ids.append({command_pid: [command]})
77 fpid=open(filedict,'w')
78 pickle.dump(process_ids, fpid)
81 print "addToKillList: can not add command %s to the kill list"% filedict
87 my_port = findFileDict()
88 from killSalomeWithPort import getPiDict
89 filedict=getPiDict(my_port)
91 fpid=open(filedict, 'r')
92 process_ids=pickle.load(fpid)
98 for process_id in process_ids:
100 for pid, cmd in process_id.items():
101 print "stop process %s : %s"% (pid, cmd[0])
103 os.kill(int(pid),signal.SIGKILL)
105 print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
114 if __name__ == "__main__":
115 if verbose(): print sys.argv
116 addToKillList(sys.argv[1], sys.argv[2])