From ea4e5e8c82ac97cf389e07d9aa2251b1bfc344bb Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 19 Aug 2026 11:58:31 -0700 Subject: [PATCH] fix(macos): stop reusing exited managed processes --- apps/macos/Sources/OpenClaw/ManagedProcess.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/macos/Sources/OpenClaw/ManagedProcess.swift b/apps/macos/Sources/OpenClaw/ManagedProcess.swift index 899268025c71..30942d5273fe 100644 --- a/apps/macos/Sources/OpenClaw/ManagedProcess.swift +++ b/apps/macos/Sources/OpenClaw/ManagedProcess.swift @@ -112,9 +112,17 @@ final class ManagedProcess: @unchecked Sendable { identifier: pid, eventMask: .exit, queue: .global(qos: .userInitiated)) - exitSource.setEventHandler { wakeContinuation.yield(.exited) } + exitSource.setEventHandler { + // The leader's exit is the operational liveness boundary; group cleanup + // may continue afterward, but callers must not reuse the dead process. + state.finish() + wakeContinuation.yield(.exited) + } exitSource.resume() - if State.hasExited(pid) { wakeContinuation.yield(.exited) } + if State.hasExited(pid) { + state.finish() + wakeContinuation.yield(.exited) + } var wakeIterator = wakeEvents.makeAsyncIterator() let wakeReason = await wakeIterator.next() ?? .terminate(gracefully: true) exitSource.cancel()