diff --git a/src/mumble/Plugins.cpp b/src/mumble/Plugins.cpp index ba1d6dea1..d5fa62e3c 100644 --- a/src/mumble/Plugins.cpp +++ b/src/mumble/Plugins.cpp @@ -473,7 +473,7 @@ void Plugins::on_Timer_timeout() { iPluginTry = 0; std::multimap pids; -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) PROCESSENTRY32 pe; pe.dwSize = sizeof(pe); @@ -487,6 +487,34 @@ void Plugins::on_Timer_timeout() { } CloseHandle(hSnap); } +#elif defined(Q_OS_LINUX) + QDir d(QLatin1String("/proc")); + QStringList entries = d.entryList(); + bool ok; + foreach (const QString &entry, entries) { + // Check if the entry is a PID + // by checking whether it's a number. + // If it is not, skip it. + unsigned long long int pid = static_cast(entry.toLongLong(&ok, 10)); + if (!ok) { + continue; + } + + QString exe = QFile::symLinkTarget(QString(QLatin1String("/proc/%1/exe")).arg(entry)); + QFileInfo fi(exe); + QString firstPart = fi.baseName(); + QString completeSuffix = fi.completeSuffix(); + QString baseName; + if (completeSuffix.isEmpty()) { + baseName = firstPart; + } else { + baseName = firstPart + QLatin1String(".") + completeSuffix; + } + + if (!baseName.isEmpty()) { + pids.insert(std::pair(baseName.toStdWString(), pid)); + } + } #endif PluginInfo *pi = qlPlugins.at(iPluginTry);