fix(worker): kill spawned claude trees when the worker dies
Spawned claude processes were only torn down on graceful cancellation (Process.Kill(entireProcessTree)). A hard worker death — Task Manager End Task, crash, OS restart, installer update — ran no cleanup, orphaning the claude->node->conhost tree, which lingered and piled up across restarts. Assign every spawned claude process to a Windows Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. The worker holds the only handle, so when it terminates for any reason the OS tears down the whole job. No-op on non-Windows; best-effort with a one-time warning if the Win32 calls fail.
This commit is contained in:
@@ -46,6 +46,7 @@ public sealed class ClaudeProcess : IClaudeProcess
|
||||
|
||||
using var process = new Process { StartInfo = psi };
|
||||
process.Start();
|
||||
ProcessJobObject.Assign(process, _logger);
|
||||
|
||||
await process.StandardInput.WriteAsync(prompt);
|
||||
process.StandardInput.Close();
|
||||
|
||||
Reference in New Issue
Block a user