Commit 8f14577
committed
fix: kill entire process group on agent close to prevent orphan child processes
kiro-cli is a wrapper that forks kiro-cli-chat as the actual ACP server.
Sending SIGTERM to the wrapper (kiro-cli) does not kill the child process
(kiro-cli-chat), which becomes an orphan and accumulates over time.
Fix: spawn the agent with detached:true so it becomes a process group
leader, then use process.kill(-pgid, SIGTERM) to kill the entire process
group including all child processes.
Also adds onAgentPid callback to runQueuedTask/runSessionPrompt to allow
callers to track the agent pid for cleanup purposes.
Fixes: kiro-cli-chat acp process leak on /new1 parent ef1fd90 commit 8f14577
2 files changed
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
375 | 376 | | |
376 | 377 | | |
377 | 378 | | |
| |||
718 | 719 | | |
719 | 720 | | |
720 | 721 | | |
721 | | - | |
722 | | - | |
| 722 | + | |
| 723 | + | |
723 | 724 | | |
724 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
725 | 730 | | |
726 | 731 | | |
727 | 732 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
| 295 | + | |
294 | 296 | | |
295 | 297 | | |
296 | 298 | | |
| |||
314 | 316 | | |
315 | 317 | | |
316 | 318 | | |
| 319 | + | |
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| |||
448 | 451 | | |
449 | 452 | | |
450 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
451 | 457 | | |
452 | 458 | | |
453 | 459 | | |
| |||
745 | 751 | | |
746 | 752 | | |
747 | 753 | | |
| 754 | + | |
748 | 755 | | |
749 | 756 | | |
750 | 757 | | |
| |||
857 | 864 | | |
858 | 865 | | |
859 | 866 | | |
860 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
861 | 870 | | |
862 | 871 | | |
863 | 872 | | |
864 | 873 | | |
865 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
866 | 878 | | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
867 | 884 | | |
868 | 885 | | |
869 | 886 | | |
| |||
872 | 889 | | |
873 | 890 | | |
874 | 891 | | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
875 | 901 | | |
876 | 902 | | |
877 | 903 | | |
| |||
0 commit comments