I'm starting a Python subprocess with this command:
p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, start_new_session=True)
As per this answer, start_new_session=True (equvalent to preexec_fn=os.setsid) allows me to terminate the process with os.killpg(p.pid, signal.SIGTERM).
However, if command happens to be something like setsid sleep 10000, the process isn't terminated. In Python, how can I terminate subprocesses like these as well?