summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBernat Arlandis <berarma@hotmail.com>2023-07-05 10:17:00 +0200
committerBernat Arlandis <berarma@hotmail.com>2023-07-05 10:17:00 +0200
commit1e60eb97b75b1f9d204a8ed19da36a95f788fb7d (patch)
tree85879ccdbdaea0cb7ffc54a22bafff5abc057ed9
parent689332f5b6cdae4919dc3efcb2e9eb2c3d8c34f9 (diff)
Migrate to procps-ng 4.0
-rw-r--r--compat/process-list.hpp30
-rw-r--r--gui/CMakeLists.txt2
2 files changed, 17 insertions, 15 deletions
diff --git a/compat/process-list.hpp b/compat/process-list.hpp
index 782dc0a4..434766cb 100644
--- a/compat/process-list.hpp
+++ b/compat/process-list.hpp
@@ -131,33 +131,35 @@ 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;
+
+ 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])
{
- QString tmp(proc->cmdline[0]);
+ QString tmp(p_cmdline[0]);
const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/'));
tmp = tmp.mid(idx == -1 ? 0 : idx+1);
ret.append(tmp);
}
- freeproc(procs[i]);
}
- free(procs);
+
+ 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)