There is a persistent process which I desire to persistently kill. To do so, I made a very simple python script:
import os
import signal
While True:
os.system("ps >> /sdcard/newdata.txt")
file = open("/sdcard/newdata.txt","r")
for x in file:
if (len(x.split())<9):
continue
elif (x.split()[8] == "/system/bin/XXXX"):
pid = int(x.split()[1])
os.kill(pid, signal.SIGKILL)
break
file.close()
the XXXX represents the name of the binary of the file which triggers the process. In my specific case this binary, XXXX, is a good way of recognizing the process I want to kill.
I think it should work, but instead it returns an error:
"ProcessLookupError: [Errno 3] No such process"
I printed the pid and ran the script multiple times. The pid is fixed which should mean the process didn't respawn, still it always returns an error as if the pid is wrong.
Can anyone explain this?