mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Processes (Linux): fix implementation
`sysinfo.procs` reports number of all running threads, instead of processes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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