From 7334c864438a7c64861755b92acc7f031471e7a2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 20 May 2025 10:04:58 +0200 Subject: [PATCH] Utils: Use "exe" column from ps On Linux we can get the executable name directly via the "exe" column. On macOS we can continue to use "comm" which gives us the same information there. "comm" on Linux though is the current value of the processes "argv[0]". Amends 2d0fc6a3ba4aa9338d66ca3a7954bf01beb113e5 Change-Id: I6405f08e815806bb7edd9654f2891701320f5e3d Reviewed-by: Christian Kandeler Reviewed-by: hjk --- src/libs/utils/processinfo.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/utils/processinfo.cpp b/src/libs/utils/processinfo.cpp index 433b8548187..8f0eceb5060 100644 --- a/src/libs/utils/processinfo.cpp +++ b/src/libs/utils/processinfo.cpp @@ -148,11 +148,13 @@ static Result> getLocalProcessesUsingPs(const FilePath &devic // cmdLines are full command lines, usually with absolute path, // exeNames only the file part of the executable's path. - const auto exeNames = getLocalProcessDataUsingPs(ps, "comm"); + using namespace Qt::Literals; + const QString exeNameColumn = deviceRoot.osType() == OsTypeMac ? "comm"_L1 : "exe"_L1; + const Result> exeNames = getLocalProcessDataUsingPs(ps, exeNameColumn); if (!exeNames) return ResultError(exeNames.error()); - const auto cmdLines = getLocalProcessDataUsingPs(ps, "args"); + const Result> cmdLines = getLocalProcessDataUsingPs(ps, "args"); if (!cmdLines) return ResultError(cmdLines.error()); @@ -166,10 +168,7 @@ static Result> getLocalProcessesUsingPs(const FilePath &devic const QString exeName = it.value(); if (exeName.isEmpty()) continue; - const int pos = cmdLine.indexOf(exeName); - if (pos == -1) - continue; - processes.append({pid, cmdLine.left(pos + exeName.size()), cmdLine}); + processes.append({pid, exeName, cmdLine}); } return processes;