Processes (GNU): uses native impl

This commit is contained in:
Carter Li
2026-08-24 22:43:37 +08:00
committed by 李通洲
parent 83cc7a94a4
commit b5897f784f
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -1388,7 +1388,7 @@ elseif(GNU)
src/detection/packages/packages_linux.c
src/detection/packages/packages_nix.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_linux.c
src/detection/processes/processes_gnu.c
src/detection/gtk_qt/qt.c
src/detection/sound/sound_linux.c
src/detection/swap/swap_linux.c
+33
View File
@@ -0,0 +1,33 @@
#include "processes.h"
#include <hurd.h>
#include <ps.h>
const char* ffDetectProcesses(uint32_t* result) {
struct ps_context* context = nullptr;
if (ps_context_create(getproc(), &context) != 0) {
return "ps_context_create(getproc()) failed";
}
const char* error = nullptr;
struct proc_stat_list* list = nullptr;
if (proc_stat_list_create(context, &list) != 0) {
error = "proc_stat_list_create() failed";
goto done;
}
// No flags are needed; we only count the processes.
if (proc_stat_list_add_all(list, nullptr, nullptr) != 0) {
error = "proc_stat_list_add_all() failed";
goto done;
}
*result = (uint32_t) list->num_procs;
done:
if (list) {
proc_stat_list_free(list);
}
ps_context_free(context);
return error;
}