Skip to content

Commit

Permalink
Use taskkill to kill processes on Windows (microsoft#22286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored Oct 23, 2023
1 parent daab11d commit 9e07503
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/client/common/process/rawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export function shellExec(
const disposable: IDisposable = {
dispose: () => {
if (!proc.killed) {
proc.kill();
if (proc.pid) {
killPid(proc.pid);
} else {
proc.kill();
}
}
},
};
Expand Down Expand Up @@ -101,7 +105,11 @@ export function plainExec(
const disposable: IDisposable = {
dispose: () => {
if (!proc.killed) {
proc.kill();
if (proc.pid) {
killPid(proc.pid);
} else {
proc.kill();
}
}
},
};
Expand Down Expand Up @@ -219,7 +227,11 @@ export function execObservable(
internalDisposables.push(
options.token.onCancellationRequested(() => {
if (!procExited && !proc.killed) {
proc.kill();
if (proc.pid) {
killPid(proc.pid);
} else {
proc.kill();
}
procExited = true;
}
}),
Expand Down Expand Up @@ -279,6 +291,6 @@ export function killPid(pid: number): void {
process.kill(pid);
}
} catch {
// Ignore.
traceVerbose('Unable to kill process with pid', pid);
}
}

0 comments on commit 9e07503

Please sign in to comment.