Commit 216174e
fix: kill entire process group on timeout and reset to prevent orphaned MCP servers
When a session ends via SIGKILL (idle/absolute timeout or /reset), only the
top-level agent-runner node process was killed. MCP servers spawned inside it
by the Claude Agent SDK became orphaned — reparented to launchd and left running.
Spawn agents with detached=true to create a new process group. Use
process.kill(-pid, signal) in killOnTimeout and killAgent so the entire
group is torn down together.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 59f9bf4 commit 216174e
2 files changed
Lines changed: 28 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
| |||
408 | 412 | | |
409 | 413 | | |
410 | 414 | | |
| 415 | + | |
411 | 416 | | |
412 | | - | |
| 417 | + | |
413 | 418 | | |
414 | | - | |
415 | | - | |
| 419 | + | |
| 420 | + | |
416 | 421 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
421 | 429 | | |
422 | 430 | | |
423 | | - | |
| 431 | + | |
424 | 432 | | |
425 | | - | |
| 433 | + | |
426 | 434 | | |
427 | 435 | | |
428 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
| |||
0 commit comments