Merge pull request #1890 from a0000001/fix/win-process-tree-kill

fix: kill process tree on Windows via taskkill before SIGTERM fallback
This commit is contained in:
Bohdan Triapitsyn
2026-08-27 23:15:45 +03:00
committed by GitHub
+14
View File
@@ -171,6 +171,19 @@ function stripWrappingQuotes(value: string): string {
return trimmed;
}
function killProcessTree(pid: number | undefined): void {
if (!Number.isInteger(pid)) return;
if (process.platform === 'win32') {
try {
spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], {
stdio: 'ignore', timeout: 5000, windowsHide: true,
});
} catch {
// ignore
}
}
}
function appendToPath(dir: string) {
const trimmed = (dir || '').trim();
if (!trimmed) return;
@@ -753,6 +766,7 @@ async function spawnManagedOpenCodeServer(
return {
url,
close: () => {
killProcessTree(child.pid);
try {
child.kill('SIGTERM');
} catch {