Answers for "kill python process using subprocess"

4

linux kill all python processes

sudo pkill -9 python
Posted by: Guest on May-25-2021
0

stop a subprocess python

import os
import signal
import subprocess

# The os.setsid() is passed in the argument preexec_fn so
# it's run after the fork() and before  exec() to run the shell.
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE, 
                       shell=True, preexec_fn=os.setsid) 

os.killpg(os.getpgid(pro.pid), signal.SIGTERM)  # Send the signal to all the process groups
Posted by: Guest on July-18-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language