Killing a process created with Python's subprocess.Popen() [duplicate] Killing a process created with Python's subprocess.Popen() [duplicate] python python

Killing a process created with Python's subprocess.Popen() [duplicate]


In your code it should be

proc1.kill()

Both kill or terminate are methods of the Popen object. On macOS and Linux, kill sends the signal signal.SIGKILL to the process and terminate sends signal.SIGTERM. On Windows they both call Windows' TerminateProcess() function.


process.terminate() doesn't work when using shell=True. This answer will help you.


Only use Popen kill method

process = subprocess.Popen(    task.getExecutable(),     stdout=subprocess.PIPE,     stderr=subprocess.PIPE,     shell=True)process.kill()