Is it possible to kill a process of another user with python by using:
import subprocess
def killProcess(pid):
p = subprocess.Popen(['sudo','kill','-9',str(pid)], stdout=subprocess.PIPE)
Because if I execute this, nothing happens. If I execute sudo kill -9 pid in terminal no matter which user Iam logged in it workds. So I think there is something wrong with my Popen execution. I try to kill subprocesses spawned with pythons multiprocessing module. Each of those subprocesses creates tensorflow instances. When the main process has killed the subprocesses still blocking the GPUs memory and therefore has to be killed.
I also tried the psutil.Process(pid).terminate()
approach. But then I get the error message:
AccessDenied: psutil.AccessDenied (pid=326080)
Anyone has an idea?
Best regards!