Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasktools.cpp
Show First 20 Lines • Show All 497 Lines • ▼ Show 20 Line(s) | 497 | { | |||
---|---|---|---|---|---|
498 | if (pid == 0) { | 498 | if (pid == 0) { | ||
499 | return KService::List(); | 499 | return KService::List(); | ||
500 | } | 500 | } | ||
501 | 501 | | |||
502 | if (!rulesConfig) { | 502 | if (!rulesConfig) { | ||
503 | return KService::List(); | 503 | return KService::List(); | ||
504 | } | 504 | } | ||
505 | 505 | | |||
506 | // Read the BAMF_DESKTOP_FILE_HINT environment variable which contains the actual desktop file path for Snaps. | ||||
507 | QFile environFile(QStringLiteral("/proc/%1/environ").arg(QString::number(pid))); | ||||
508 | if (environFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||||
509 | const QByteArray bamfDesktopFileHint = QByteArrayLiteral("BAMF_DESKTOP_FILE_HINT"); | ||||
510 | | ||||
511 | const auto lines = environFile.readAll().split('\0'); | ||||
512 | for (const QByteArray &line : lines) { | ||||
513 | const int equalsIdx = line.indexOf('='); | ||||
514 | if (equalsIdx <= 0) { | ||||
515 | continue; | ||||
516 | } | ||||
517 | | ||||
518 | const QByteArray key = line.left(equalsIdx); | ||||
519 | if (key == bamfDesktopFileHint) { | ||||
520 | const QByteArray value = line.mid(equalsIdx + 1); | ||||
521 | | ||||
522 | KService::Ptr service = KService::serviceByDesktopPath(QString::fromUtf8(value)); | ||||
523 | if (service) { | ||||
524 | return {service}; | ||||
525 | } | ||||
526 | break; | ||||
527 | } | ||||
528 | } | ||||
529 | } | ||||
530 | | ||||
506 | auto proc = KProcessList::processInfo(pid); | 531 | auto proc = KProcessList::processInfo(pid); | ||
507 | if (!proc.isValid()) { | 532 | if (!proc.isValid()) { | ||
508 | return KService::List(); | 533 | return KService::List(); | ||
509 | } | 534 | } | ||
510 | 535 | | |||
511 | const QString cmdLine = proc.command(); | 536 | const QString cmdLine = proc.command(); | ||
512 | 537 | | |||
513 | if (cmdLine.isEmpty()) { | 538 | if (cmdLine.isEmpty()) { | ||
▲ Show 20 Lines • Show All 294 Lines • Show Last 20 Lines |