This is an automated email from the ASF dual-hosted git repository.

rstrickland pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new b3e25a9  update stopDebugging to kill terminals based on name
b3e25a9 is described below

commit b3e25a9b8eba71c41f6b42009bfc7c644ab88814
Author: DuBois Ford <[email protected]>
AuthorDate: Tue Sep 2 13:14:14 2025 -0400

    update stopDebugging to kill terminals based on name
---
 src/daffodilDebugger/utils.ts | 23 ++++++++++++++++++-----
 src/utils.ts                  |  2 +-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/daffodilDebugger/utils.ts b/src/daffodilDebugger/utils.ts
index eb32ead..68aad43 100644
--- a/src/daffodilDebugger/utils.ts
+++ b/src/daffodilDebugger/utils.ts
@@ -26,7 +26,7 @@ import { deactivate } from '../adapter/extension'
 import { getDaffodilVersion } from './daffodil'
 import { Artifact } from '../classes/artifact'
 import { DFDLDebugger } from '../classes/dfdlDebugger'
-import { osCheck, runScript } from '../utils'
+import { osCheck, runScript, terminalName } from '../utils'
 
 export const daffodilVersion = (filePath: string): string => {
   return getDaffodilVersion(filePath)
@@ -130,10 +130,23 @@ function latestJdk(jdkHomes: IJavaHomeInfo[]): 
IJavaHomeInfo | undefined {
 export async function stopDebugging() {
   vscode.debug.stopDebugging().then(async () => {
     deactivate()
-    for (const t of vscode.window.terminals) {
-      await t.processId?.then(async (id) => {
-        await stopDebugger(id)
-      })
+    for (const terminal of vscode.window.terminals) {
+      const pid = await terminal.processId
+
+      // Only kill known debug terminals created by the extension itself
+      if (terminal.name.toLowerCase().includes(terminalName)) {
+        terminal.dispose()
+
+        // Wait briefly to allow dispose to take effect
+        await new Promise((res) => setTimeout(res, 200))
+
+        // If terminal still exists, fallback to stopDebugger
+        // "stopDebugger" uses taskkill or kill which results in an exit code 
of 1
+        const stillExists = vscode.window.terminals.some((t) => t === terminal)
+        if (stillExists && pid) {
+          await stopDebugger(pid)
+        }
+      }
     }
   })
 }
diff --git a/src/utils.ts b/src/utils.ts
index 15068f1..5242fb3 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -27,7 +27,7 @@ import { XMLParser } from 'fast-xml-parser'
 
 let currentConfig: vscode.DebugConfiguration
 
-const terminalName = 'daffodil-debugger'
+export const terminalName = 'daffodil-debugger'
 
 export const regexp = {
   comma: new RegExp(',', 'g'),

Reply via email to