diff --git a/CHANGELOG.md b/CHANGELOG.md index 7effc2ceb..2a663a8f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Bugfixes: * Fix possible crashes caused by uninitialized strings (Users, Windows) * Improve support of `--help *-format` and several bugs are found and fixed * Don't incorrectly print `No active sound devices found` when using a non-controllable sound device (Sound, macOS) +* Fix implementation processes counting (Processes, Linux) Logo: * Add Chimera Linux diff --git a/src/detection/processes/processes_linux.c b/src/detection/processes/processes_linux.c index 7e17fbc9a..cff71038c 100644 --- a/src/detection/processes/processes_linux.c +++ b/src/detection/processes/processes_linux.c @@ -1,13 +1,25 @@ #include "processes.h" -#include +#include "common/io/io.h" + +#include const char* ffDetectProcesses(uint32_t* result) { - struct sysinfo info; - if(sysinfo(&info) != 0) - return "sysinfo() failed"; + FF_AUTO_CLOSE_DIR DIR* dir = opendir("/proc"); + if(dir == NULL) + return "opendir(\"/proc\") failed"; + + uint32_t num = 0; + + struct dirent* entry; + while ((entry = readdir(dir)) != NULL) + { + if (entry->d_type == DT_DIR && isdigit(entry->d_name[0])) + ++num; + } + + *result = num; - *result = (uint32_t) info.procs; return NULL; }