diff options
author | Bernat Arlandis <berarma@hotmail.com> | 2023-07-05 10:17:00 +0200 |
---|---|---|
committer | Bernat Arlandis <berarma@hotmail.com> | 2023-07-05 10:17:00 +0200 |
commit | 1e60eb97b75b1f9d204a8ed19da36a95f788fb7d (patch) | |
tree | 85879ccdbdaea0cb7ffc54a22bafff5abc057ed9 /compat | |
parent | 689332f5b6cdae4919dc3efcb2e9eb2c3d8c34f9 (diff) |
Migrate to procps-ng 4.0
Diffstat (limited to 'compat')
-rw-r--r-- | compat/process-list.hpp | 30 |
1 files changed, 16 insertions, 14 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; } |