-
- if not sys.platform == 'win32':
- cmd = "pid=`ps -fea | grep '"+os.getenv('USER')+"' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'` ; echo $pid > /tmp/logs/"+os.getenv('USER')+"/_"+"Pid_ghs3d.log"
- a = os.system(cmd)
- try:
- fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+"Pid_ghs3d.log")
- prc = fpidomniNames.read()
- fpidomniNames.close()
- if prc != None :
- for field in prc.split(" ") :
- field = field.strip()
- if field != None and len(field) != 0:
- os.system('kill -9 '+field)
- except:
+ except:
+ pass
+ # provide compatibility with old-style pidict file (not dot-prefixed)
+ #fpidict = getPiDict('(\d*)',hidden=False)
+ fpidict = getPiDict('#####',hidden=False)
+ dirpidict = os.path.dirname(fpidict)
+ fpidict = os.path.basename(fpidict)
+ #if hostname in fpidict:
+ # fpidict = fpidict.replace(hostname, shostname+".*")
+ fpidict = fpidict.replace('#####', '(\d*)')
+ fnamere = re.compile("^%s$" % fpidict)
+ try:
+ for f in os.listdir(dirpidict):
+ mo = fnamere.match(f)
+ try:
+ killMyPort(mo.group(1))
+ except:
+ pass
+ pass
+ pass
+ except:
+ pass
+ # kill other processes
+ if sys.platform != 'win32':
+ import commands
+ cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
+ prc = commands.getoutput(cmd)
+ for field in prc.split():
+ try:
+ os.kill(int(field), signal.SIGKILL)
+ except:
+ pass
+ pass
+ pass
+ # kill ompi-server needed for MPI containers coupling
+ cmd = "ps -fea | grep '%s' | grep 'ompi-server' | grep -v 'grep' | awk '{print $2}'" % user
+ prc = commands.getoutput(cmd)
+ for field in prc.split():
+ try:
+ os.kill(int(field), signal.SIGKILL)
+ except:
+ pass