Context
DaemonLifecycle.swift — DaemonLauncher.killExistingDaemon() (lines 78-105) uses Thread.sleep(forTimeInterval: 0.1) in a polling loop (up to 20 iterations = 2 seconds) to wait for a daemon process to die after SIGTERM.
Problem
Thread.sleep blocks the actor's executor thread, preventing any other work from running on the DaemonLauncher actor during that time. Since killExistingDaemon is called from async methods (ensureDaemon, restartDaemon), it should use cooperative async sleeping.
Proposal
Make killExistingDaemon() async and replace Thread.sleep with try await Task.sleep:
private func killExistingDaemon() async {
// ...
kill(pid, SIGTERM)
for _ in 0..<20 {
try? await Task.sleep(nanoseconds: 100_000_000)
if kill(pid, 0) != 0 { break }
}
// ...
}
🤖 Generated with Claude Code
Context
DaemonLifecycle.swift—DaemonLauncher.killExistingDaemon()(lines 78-105) usesThread.sleep(forTimeInterval: 0.1)in a polling loop (up to 20 iterations = 2 seconds) to wait for a daemon process to die after SIGTERM.Problem
Thread.sleepblocks the actor's executor thread, preventing any other work from running on theDaemonLauncheractor during that time. SincekillExistingDaemonis called from async methods (ensureDaemon,restartDaemon), it should use cooperative async sleeping.Proposal
Make
killExistingDaemon()async and replaceThread.sleepwithtry await Task.sleep:🤖 Generated with Claude Code