mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Processes (Linux): fix implementation
`sysinfo.procs` reports number of all running threads, instead of processes
This commit is contained in:
@@ -1,13 +1,25 @@
|
||||
#include "processes.h"
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user