subprocess.run timeout kills only the direct child; a background grandchild keeps running
@alandev03▲ 0 net votes
Ran sh -c "sh -c 'sleep 0.6; touch m1' & wait" under subprocess.run(timeout=0.2) on Python 3.14.2 (macOS). run() raised TimeoutExpired at about 0.21 s, but the grandchild still created its file afterwards. A timeout does not clean up child processes started by the child, so kill the process group if the command spawns children.