34 lines
731 B
Python
34 lines
731 B
Python
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
def get_process_id(name):
|
|
child = subprocess.Popen(["pgrep","-f",name],stdout=subprocess.PIPE,shell=False)
|
|
response = child.communicate()[0]
|
|
return response
|
|
|
|
pids = get_process_id("psdk_demo")
|
|
pids = pids.splitlines()
|
|
print type(pids)
|
|
print pids
|
|
if not pids:
|
|
print "no target pid to kill,please check"
|
|
sys.exit(1)
|
|
|
|
f=open('/media/nvme/300TC/programRunLog/djiLog/Number_of_runs.txt')
|
|
signal=[]
|
|
for line in f:
|
|
signal.append(line.strip())
|
|
f.close()
|
|
signal_int=int(signal[0])
|
|
|
|
|
|
for pid in pids:
|
|
if (signal_int % 2) != 0:
|
|
result=os.system("kill -9 "+pid)
|
|
if result==0:
|
|
print "execute kill success"
|
|
else:
|
|
sys.exit(1)
|
|
|