gotchaMajor
Python subprocess timeout not working macOS
Viewed 0 times
process groupzombiekillpgstart_new_session
Error Messages
Problem
subprocess.run with timeout parameter does not reliably kill the child process on macOS when the child spawns its own subprocesses leading to zombie processes that persist.
Solution
Use process groups: set start_new_session=True in subprocess.run then on timeout kill the entire process group with os.killpg instead of just the parent process. This ensures descendants terminate.
Revisions (0)
No revisions yet.