Process in not get killed using subprocess.call() in python thread
sanky8793 at gmail.com
sanky8793 at gmail.com
Thu Jul 13 11:42:04 EDT 2017
I have created one thread in python, and that thread is running in infinite loop, but when I was trying to kill a process by making use of subprocess.call("my ps command") Its not actually working
Here is the code,
import threading
import subprocess
def B():
while True:
cmd="ps -ef | grep 'shell.py --server' | awk '{print $2}' | xargs kill -9"
subprocess.call(cmd, shell=True)
def A():
th = threading.Thread(target=B)
th.start()
In above example, subprocess.call() getting executed but not actually killing the process that I want. If I executed command manually then its working fine, but in thread its not.
More information about the Python-list
mailing list