From 1b70669cc37d466b79b35cf6313549ca64f7addd Mon Sep 17 00:00:00 2001 From: allenbenz Date: Fri, 10 Dec 2021 19:40:47 -0800 Subject: [PATCH] Stop dotnet watch processes on windows when closing vscode. --- src/executor.ts | 13 +++++++++++-- src/extension.ts | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/executor.ts b/src/executor.ts index 7b67d4e..82be742 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -118,13 +118,22 @@ export class Executor { } public static stop() { - this.processes.forEach((p) => { + const killPromises = this.processes.map((p) => { Logger.Log(`Stop processes requested - ${p.pid} stopped`); - p.kill("SIGKILL"); + return new Promise(resolve => { + if (this.isWindows) { + exec(`taskkill /pid ${p.pid} /T /F`).on('close',() => resolve(null)); + } else { + p.kill("SIGKILL"); + resolve(null); + } + }); }); this.processes = []; this.debugRunnerInfo = null; + + return Promise.all(killPromises); } private static debugRunnerInfo: IDebugRunnerInfo; diff --git a/src/extension.ts b/src/extension.ts index 0487da3..96217db 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -122,4 +122,5 @@ export function activate(context: vscode.ExtensionContext) { } export function deactivate() { + return Executor.stop(); }