diff --git a/src/pickProcess.ts b/src/pickProcess.ts index f17815bbb8..2766550408 100644 --- a/src/pickProcess.ts +++ b/src/pickProcess.ts @@ -60,12 +60,12 @@ export interface ProcessListCommand { async function getGoProcesses(): Promise { const processes = await getAllProcesses(); - // TODO(suzmue): set the executable path for win32 and darwin. - if (process.platform !== 'linux') { + // TODO(suzmue): set the executable path for and darwin. + if (process.platform === 'darwin') { return processes; } - // Run 'go version' on all of /proc/${pid}/exe to find 'go' processes + // Run 'go version' on all executable paths to find 'go' processes const goRuntimePath = getBinPath('go'); if (!goRuntimePath) { vscode.window.showErrorMessage( @@ -94,7 +94,7 @@ async function getGoProcesses(): Promise { const goProcesses: AttachItem[] = []; processes.forEach((item) => { - if (goProcessExes.indexOf(item.id) >= 0) { + if (goProcessExes.indexOf(item.executable) >= 0) { item.isGo = true; goProcesses.push(item); } diff --git a/src/utils/wmicProcessParser.ts b/src/utils/wmicProcessParser.ts index 9b20883532..721b39d8a5 100644 --- a/src/utils/wmicProcessParser.ts +++ b/src/utils/wmicProcessParser.ts @@ -4,8 +4,9 @@ * Licensed under the MIT License. See LICENSE in the project root for license information. *--------------------------------------------------------*/ -// Taken from: -// https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/extension/attachQuickPick/wmicProcessParser.ts +// Modified from: +// https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/extension/attachQuickPick/wmicProcessParser.ts. +// Added arguments to get the ExecutablePath from wmic. 'use strict'; @@ -14,6 +15,7 @@ import { AttachItem, ProcessListCommand } from '../pickProcess'; const wmicNameTitle = 'Name'; const wmicCommandLineTitle = 'CommandLine'; const wmicPidTitle = 'ProcessId'; +const wmicExecutableTitle = 'ExecutablePath'; const defaultEmptyEntry: AttachItem = { label: '', description: '', @@ -32,7 +34,7 @@ const defaultEmptyEntry: AttachItem = { // | 1308 | 1132 | export const wmicCommand: ProcessListCommand = { command: 'wmic', - args: ['process', 'get', 'Name,ProcessId,CommandLine', '/FORMAT:list'] + args: ['process', 'get', 'Name,ProcessId,CommandLine,ExecutablePath', '/FORMAT:list'] }; export function parseWmicProcesses(processes: string): AttachItem[] { @@ -79,6 +81,8 @@ function parseLineFromWmic(line: string, item: AttachItem): AttachItem { currentItem.detail = value; currentItem.commandLine = value; + } else if (key === wmicExecutableTitle) { + currentItem.executable = value; } }