Inherit parent's app ID when creating a new cgroup for tabs

When creating a cgroup for a tab, we would use a hardcoded string as
cgroup name that included `org.kde.konsole` as app ID. This leads to
tabs incorrectly being attributed to Konsole in System Monitor's
application page, even if the tab is actually embedded in a different
application such as Kate.

Instead of hardcoding the app ID, use the application's desktop file
name, so that if we lookup the app ID from a cgroup name, we get back to
the original application instead of Konsole.

BUG: 508716
This commit is contained in:
Arjen Hiemstra
2025-06-03 16:08:17 +02:00
committed by Christoph Cullmann
parent 0c943db0f7
commit 78b2f295fb

View File

@@ -11,6 +11,7 @@
#include "NullProcessInfo.h"
#include "ProcessInfo.h"
#include "UnixProcessInfo.h"
#include "konsoledebug.h"
// Unix
#ifndef Q_OS_WIN
@@ -26,6 +27,7 @@
// Qt
#include <QDir>
#include <QFileInfo>
#include <QGuiApplication>
#include <QHostInfo>
#include <QStringList>
#include <QTextStream>
@@ -624,7 +626,6 @@ private:
const pid_t selfPid = getpid();
const QString managerObjPath(QStringLiteral("/org/freedesktop/systemd1"));
const QString appUnitName(QStringLiteral("app-org.kde.konsole-%1.scope").arg(selfPid));
// check if systemd dbus services exist
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.systemd1"))) {
@@ -634,6 +635,9 @@ private:
// get current application cgroup path
const QString oldAppCGroupPath(getProcCGroup(selfPid));
auto appUnitName = QStringLiteral("app-%1-%2.scope").arg(QGuiApplication::desktopFileName()).arg(selfPid);
qCDebug(KonsoleDebug) << "Creating scope" << appUnitName;
// create application unit
VariantList properties;
const QList<uint> mainPid({static_cast<quint32>(selfPid)});