shell=Truestarts a new shell process. proc.pidis the pid of this shell process. kill -9kills the shell process, turning the grandson python process into orphans.
python script , python, = True:
import os
import signal
import subprocess
proc = subprocess.Popen("python script.py", shell=True, preexec_fn=os.setsid)
os.killpg(proc.pid, signal.SIGTERM)
script.py , @icktoofay: shell=True, proc.terminate() proc.kill() - :
import subprocess
proc = subprocess.Popen(["python", "script.py"])
proc.terminate()
script ; get_script_dir() .
python , (, multiprocessing) , script. , get_script_dir() multiprocessing .