3 import os, sys, pickle, string, signal
5 ########## adds to the kill list of SALOME one more process ##########
8 if os.environ.has_key('NSPORT'):
9 my_port = os.environ['NSPORT']
14 file = open(os.environ["OMNIORB_CONFIG"], "r")
17 l = string.split(s, ":")
18 if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" :
19 my_port = int(l[len(l)-1])
27 print "myport = ", my_port
30 def addToKillList(command_pid, command):
31 my_port = findFileDict()
32 from killSalomeWithPort import getPiDict
33 filedict=getPiDict(my_port)
35 fpid=open(filedict, 'r')
36 process_ids=pickle.load(fpid)
43 for process_id in process_ids:
45 for pid, cmd in process_id.items():
46 #print "see process %s : %s"% (pid, cmd[0])
47 if pid == command_pid:
53 command=(command.split(" "))[0]
56 process_ids.append({command_pid: [command]})
57 fpid=open(filedict,'w')
58 pickle.dump(process_ids, fpid)
61 print "addToKillList: can not add command %s to the kill list"% filedict
67 my_port = findFileDict()
68 from killSalomeWithPort import getPiDict
69 filedict=getPiDict(my_port)
71 fpid=open(filedict, 'r')
72 process_ids=pickle.load(fpid)
78 for process_id in process_ids:
80 for pid, cmd in process_id.items():
81 print "stop process %s : %s"% (pid, cmd[0])
83 os.kill(int(pid),signal.SIGKILL)
85 print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
94 if __name__ == "__main__":
96 addToKillList(sys.argv[1], sys.argv[2])