Skip to content

Prevent "directory not empty" crash#60

Merged
DRMacIver merged 2 commits intomainfrom
DRMacIver/empty-directory-crash
Mar 17, 2026
Merged

Prevent "directory not empty" crash#60
DRMacIver merged 2 commits intomainfrom
DRMacIver/empty-directory-crash

Conversation

@DRMacIver
Copy link
Copy Markdown
Owner

When Trio cancels a task (because another parallel candidate succeeded), trio.run_process only kills the direct child subprocess. But interestingness tests are shell scripts that spawn children (cp, timeout, lua, etc.) via setsid. These orphaned children continue writing to the temp directory, causing shutil.rmtree to fail with "OSError: Directory not empty".

Added kill_process_group() which sends SIGKILL to the entire process group on exit from run_script_on_file. Also made temp directory cleanup robust with ignore_errors=True as defense-in-depth.

Fixes #57

DRMacIver and others added 2 commits March 17, 2026 09:58
… empty crash

When Trio cancels a task (because another parallel candidate succeeded),
trio.run_process only kills the direct child subprocess. But interestingness
tests are shell scripts that spawn children (cp, timeout, lua, etc.) via
setsid. These orphaned children continue writing to the temp directory,
causing shutil.rmtree to fail with "OSError: Directory not empty".

Added kill_process_group() which sends SIGKILL to the entire process group
on exit from run_script_on_file. Also made temp directory cleanup robust
with ignore_errors=True as defense-in-depth.

Fixes #57

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
@DRMacIver DRMacIver merged commit 0afc29a into main Mar 17, 2026
@DRMacIver DRMacIver deleted the DRMacIver/empty-directory-crash branch March 17, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Directory not empty crashes

1 participant