summaryrefslogblamecommitdiffstats
path: root/For Weekly Test/Advance/procname-0.2/kill.py
blob: d99991723f8ac9479d9edaf5c02945853aca8517 (plain) (tree)
1
2
3
4
5
6


                         

                                                                                                 
 








                                                                  
 







                                                         
import subprocess, signal
import os

#kill process to make sure, that the handler is Terminate incase handler having problem receiving
# terminate message from controller

def killProc(handlerName):
	# define process name of the Handler
	if handlerName[0:3]== 'GSM':
		procName = 'GSM Handler'
	else:
		procName = 'SIP handler'
		
	p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
	out, err = p.communicate()

	#search process name and kill it.
	for line in out.splitlines():
		if procName in line:
			pid = int(line.split(None, 1)[0])
			os.kill(pid, signal.SIGKILL)


killProc('sip')