Files
fastfetch/src/detection/processes/processes_linux.c
T

29 lines
593 B
C
Raw Normal View History

2022-10-06 22:07:48 +08:00
#include "processes.h"
2026-01-06 09:13:40 +08:00
#include "util/io.h"
2024-05-28 15:34:59 +08:00
#include "util/stringUtils.h"
2022-12-28 17:18:08 +08:00
2023-04-15 10:22:46 +08:00
const char* ffDetectProcesses(uint32_t* result)
2022-10-06 22:07:48 +08:00
{
2023-10-11 21:09:43 +08:00
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)
{
2024-06-16 01:02:48 +08:00
if (
#ifdef _DIRENT_HAVE_D_TYPE
2025-08-22 14:08:18 +08:00
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
2024-06-16 01:02:48 +08:00
#endif
ffCharIsDigit(entry->d_name[0]))
2023-10-11 21:09:43 +08:00
++num;
}
*result = num;
2023-04-15 10:22:46 +08:00
return NULL;
2022-10-06 22:07:48 +08:00
}