summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-07-06 15:06:31 +0200
committerGitHub <noreply@github.com>2023-07-06 15:06:31 +0200
commit0dd9d54c5dd420237ce07ea8325ff283d9629b6d (patch)
treeb79559bb83fdaf777bd2ddafa1c11732fc25dec9
parent689332f5b6cdae4919dc3efcb2e9eb2c3d8c34f9 (diff)
parent8e5a7763626998500566ca248f7c1670f084197d (diff)
Merge pull request #1686 from berarma/procps-ng
-rw-r--r--compat/process-list.hpp37
-rw-r--r--gui/CMakeLists.txt2
2 files changed, 24 insertions, 15 deletions
diff --git a/compat/process-list.hpp b/compat/process-list.hpp
index 782dc0a4..26a5ceda 100644
--- a/compat/process-list.hpp
+++ b/compat/process-list.hpp
@@ -131,33 +131,42 @@ static QStringList get_all_executable_names()
#elif defined __linux__
-#include <proc/readproc.h>
+#include <libproc2/pids.h>
#include <cerrno>
template<typename = void>
QStringList get_all_executable_names()
{
QStringList ret;
- proc_t** procs = readproctab(PROC_FILLCOM);
- if (procs == nullptr)
- {
- qDebug() << "readproctab" << errno;
- return ret;
- }
- for (int i = 0; procs[i]; i++)
+ enum pids_item items[] = { PIDS_ID_PID, PIDS_CMD, PIDS_CMDLINE_V };
+
+ enum rel_items { rel_pid, rel_cmd, rel_cmdline };
+ struct pids_info *info = NULL;
+ struct pids_stack *stack;
+ QString tmp; tmp.reserve(64);
+
+ procps_pids_new(&info, items, 3);
+
+ while ((stack = procps_pids_get(info, PIDS_FETCH_TASKS_ONLY)))
{
+ char **p_cmdline = PIDS_VAL(rel_cmdline, strv, stack, info);
+
// note, wine sets argv[0] so no parsing like in OSX case
- auto proc = procs[i];
- if (proc->cmdline && proc->cmdline[0])
+ if (p_cmdline && p_cmdline[0] && p_cmdline[0][0] &&
+ !(p_cmdline[0][0] == '-' && !p_cmdline[0][1]))
{
- QString tmp(proc->cmdline[0]);
+ tmp = QString{p_cmdline[0]};
const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/'));
- tmp = tmp.mid(idx == -1 ? 0 : idx+1);
+ if (idx != -1)
+ tmp = tmp.mid(idx+1);
+ //qDebug() << "procps" << tmp;
ret.append(tmp);
}
- freeproc(procs[i]);
}
- free(procs);
+ //qDebug() << "-- procps end";
+
+ procps_pids_unref(&info);
+
return ret;
}
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index db2f0b9e..bc9487b8 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -11,7 +11,7 @@ target_link_libraries(${self}
if(APPLE)
target_link_libraries(${self} proc)
elseif(LINUX)
- otr_pkgconfig(${self} libprocps)
+ otr_pkgconfig(${self} libproc2)
endif()
if(NOT APPLE AND NOT WIN32)