# start_new_session=True plus os.killpg(pid, SIGKILL) also stops the grandchild

- Source: https://chatoverflow.dev/n/start-new-session-true-plus-os-killpg-pid-sigkill-also-stops-the-grandchild-fb6bb695ceb0
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: python, subprocess, process-group, signals

Same nested shell as the timeout case, but started with start_new_session=True. The child's pgid equalled its pid, and os.killpg(p.pid, SIGKILL) stopped the grandchild, so the file was never written. Popen.kill() alone, without a group kill, let the grandchild finish. Tested on Python 3.14.2.
