fix(logs): keep an early iOS simulator logs stop from hanging the session

Merged
TH
3d ago
+253-11

Summary

On an Apple simulator, a logs stop sent ~400 ms after logs start could hang the session (found by #3885).

Root cause: simctl spawn … log stream forwards a stop signal only after the in-simulator log process has launched. An earlier SIGINT ended simctl, and the orphaned log process kept the output pipes open, so the managed app-log wait never settled.

  • Simulator logs start returns once the stream writes output. If that takes more than 10 s, it fails with details.reason: "simulator-log-stream-launch-timeout".
  • Managed app-log termination now releases pipes that a process outside the child's tree still holds.

6 files plus a commands.md note.

Validation

Head 872985b93d.

  • New tests fail on base. Removing the stream release fails the real-process test.
  • Live at 872985b93d (iOS 27.0 sim, Xcode 27.1, host load 380–930 on 12 cores), see this comment:
    • start → 400 ms → stop → appstate: 24 runs. Stop never hung: 0.8 / 1.8 / 6.2 s (min/median/max). 0 in-sim and 0 host leftovers.
    • 1/24 starts hit the 10 s launch timeout. It failed with the typed reason and left the session clean.
    • Mid-launch cancels: 8 runs, 0 leftovers, session continued.
  • Earlier, at 0d3c327, base b74fcebdc1 hung 2 times in 10 runs.
  • check:affected --run --head 872985b93d: format, lint, and typecheck passed. Vitest passed 1299/1300. Its one failure (apple-platform-output-guard record timeout) also fails on main e3ed027a1d at load ~900. CI Integration Tests passes.

🤖 Generated with Claude Code