2022-10-06 22:07:48 +08:00
|
|
|
#include "processes.h"
|
|
|
|
|
|
2023-10-11 21:09:43 +08:00
|
|
|
#include "common/io/io.h"
|
|
|
|
|
|
|
|
|
|
#include <ctype.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)
|
|
|
|
|
{
|
|
|
|
|
if (entry->d_type == DT_DIR && isdigit(entry->d_name[0]))
|
|
|
|
|
++num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*result = num;
|
2023-04-15 10:22:46 +08:00
|
|
|
|
|
|
|
|
return NULL;
|
2022-10-06 22:07:48 +08:00
|
|
|
}
|