subprocess

Killing sudo-started subprocess in python

瘦欲@ 提交于 2020-08-24 07:45:13
问题 I am running with a user that can make root-level calls without having to supply a password. My user currently does something like this pr = subprocess.Popen("sudo sleep 100".split()) sleep(5) pr.kill() but that leads to this error because the user isn't root so it can't kill a root process Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/subprocess.py", line 1572, in kill self.send_signal(signal.SIGKILL) File "/usr/lib/python2.7/subprocess.py",