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:
@@ -171,6 +171,19 @@ function stripWrappingQuotes(value: string): string {
|
|||||||
return trimmed;
|
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) {
|
function appendToPath(dir: string) {
|
||||||
const trimmed = (dir || '').trim();
|
const trimmed = (dir || '').trim();
|
||||||
if (!trimmed) return;
|
if (!trimmed) return;
|
||||||
@@ -753,6 +766,7 @@ async function spawnManagedOpenCodeServer(
|
|||||||
return {
|
return {
|
||||||
url,
|
url,
|
||||||
close: () => {
|
close: () => {
|
||||||
|
killProcessTree(child.pid);
|
||||||
try {
|
try {
|
||||||
child.kill('SIGTERM');
|
child.kill('SIGTERM');
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user