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

28 lines
583 B
C
Raw Normal View History

2022-10-06 22:07:48 +08:00
#include "processes.h"
2026-01-06 09:48:38 +08:00
#include "common/io.h"
2026-05-28 15:58:08 +08:00
#include "common/strutil.h"
2022-12-28 17:18:08 +08:00
2026-03-29 09:28:49 +08:00
const char* ffDetectProcesses(uint32_t* result) {
2023-10-11 21:09:43 +08:00
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/proc");
2026-07-10 18:08:04 +08:00
if (dir == nullptr) {
2023-10-11 21:09:43 +08:00
return "opendir(\"/proc\") failed";
2026-03-29 09:28:49 +08:00
}
2023-10-11 21:09:43 +08:00
uint32_t num = 0;
struct dirent* entry;
2026-07-10 18:08:04 +08:00
while ((entry = readdir(dir)) != nullptr) {
2024-06-16 01:02:48 +08:00
if (
2026-03-29 09:28:49 +08:00
#ifdef _DIRENT_HAVE_D_TYPE
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
#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
2026-07-10 18:08:04 +08:00
return nullptr;
2022-10-06 22:07:48 +08:00
}