← ClaudeAtlas

container-green-host-red-detached-child-holds-tempdirlisted

A hook or script self-test passes in a Linux CI/factory container and fails on the Windows host where the hook actually runs. Use when: (1) a Python self-test aborts with `PermissionError: [WinError 32] The process cannot access the file because it is being used by another process` at `TemporaryDirectory` cleanup, after the early checks passed; (2) `ignore_cleanup_errors=True` on the obvious tempdir does NOT clear it; (3) the code under test launches a detached child (`subprocess.Popen(..., start_new_session=True)`) and a test runs it with `cwd=<tempdir>`; (4) a Windows-only `endswith(".claude/state/x")` path assertion fails on backslashes. The child inherited the tempdir as its cwd and holds it for its lifetime; the fix is in the product (pin the child's cwd), not the test.
MrBinnacle/skills · ★ 0 · AI & Automation · score 68
Install: claude install-skill MrBinnacle/skills
# Container-green, host-red: a detached child holds the test's tempdir ## Problem A factory/CI gate runs a hook's self-test inside a Linux container and reports green. The hook is then wired into `settings.json` (and its self-test into the session receiver checks) on a Windows host. On that host the same suite exits 1 part-way through: the first block of checks prints `ok`, then a `PermissionError [WinError 32]` traceback from `tempfile.TemporaryDirectory.__exit__`, and every later check never runs. The receiver now rejects the next session packet on a "trusted check" that never reached its second case. Observed 2026-08-29 in a private steering repository (board-drift sweep hooks): 19/19 gate checks green in-container; on the host 15/57, then abort. ## Context / Trigger Conditions - Windows host; Python 3.12/3.13; suite uses `tempfile.TemporaryDirectory()` per test. - The code under test launches a long-lived detached child: `subprocess.Popen([...], start_new_session=True)` with no `cwd=` argument. - Some test runs the parent with `subprocess.run(..., cwd=td)` where `td` is the tempdir. - Symptom order: early `ok` lines → `WinError 32 ... being used by another process: 'C:\\Users\\...\\Temp\\tmpXXXX'` naming the **directory**, not a file → suite aborts. - Red herring: the first tempdir you suspect (the one whose test polls for an output file) is not the holder. Adding `ignore_cleanup_errors=True` there changes nothing. ## Solution 1. **Find the holder by the fram