fix(coding-agent): kill tracked detached bash children on shutdown

This commit is contained in:
Armin Ronacher
2026-04-16 00:12:14 +02:00
parent 33e632dfce
commit 9b7948c4c8
5 changed files with 37 additions and 1 deletions

View File

@@ -172,6 +172,27 @@ export function sanitizeBinaryOutput(str: string): string {
.join("");
}
/**
* Detached child processes must be tracked so they can be killed on parent
* shutdown signals (SIGHUP/SIGTERM).
*/
const trackedDetachedChildPids = new Set<number>();
export function trackDetachedChildPid(pid: number): void {
trackedDetachedChildPids.add(pid);
}
export function untrackDetachedChildPid(pid: number): void {
trackedDetachedChildPids.delete(pid);
}
export function killTrackedDetachedChildren(): void {
for (const pid of trackedDetachedChildPids) {
killProcessTree(pid);
}
trackedDetachedChildPids.clear();
}
/**
* Kill a process and all its children (cross-platform)
*/