Early skip non-directories when searching for process information

This commit is contained in:
Christian Göttsche 2020-11-15 20:09:50 +01:00 committed by BenBE
parent ad72b747fa
commit f856fe6463
1 changed files with 9 additions and 4 deletions

View File

@ -389,7 +389,7 @@ static bool LinuxProcessList_readStatFile(Process* process, const char* dirname,
} }
static bool LinuxProcessList_statProcessDir(Process* process, const char* dirname, char* name) { static bool LinuxProcessList_statProcessDir(Process* process, const char* dirname, const char* name) {
char filename[MAX_NAME + 1]; char filename[MAX_NAME + 1];
filename[MAX_NAME] = '\0'; filename[MAX_NAME] = '\0';
@ -404,7 +404,7 @@ static bool LinuxProcessList_statProcessDir(Process* process, const char* dirnam
#ifdef HAVE_TASKSTATS #ifdef HAVE_TASKSTATS
static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirname, char* name, unsigned long long now) { static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirname, const char* name, unsigned long long now) {
char filename[MAX_NAME + 1]; char filename[MAX_NAME + 1];
filename[MAX_NAME] = '\0'; filename[MAX_NAME] = '\0';
@ -966,7 +966,7 @@ static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned in
static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* dirname, Process* parent, double period, struct timeval tv) { static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* dirname, Process* parent, double period, struct timeval tv) {
ProcessList* pl = (ProcessList*) this; ProcessList* pl = (ProcessList*) this;
DIR* dir; DIR* dir;
struct dirent* entry; const struct dirent* entry;
const Settings* settings = pl->settings; const Settings* settings = pl->settings;
#ifdef HAVE_TASKSTATS #ifdef HAVE_TASKSTATS
@ -981,7 +981,12 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
bool hideKernelThreads = settings->hideKernelThreads; bool hideKernelThreads = settings->hideKernelThreads;
bool hideUserlandThreads = settings->hideUserlandThreads; bool hideUserlandThreads = settings->hideUserlandThreads;
while ((entry = readdir(dir)) != NULL) { while ((entry = readdir(dir)) != NULL) {
char* name = entry->d_name; const char* name = entry->d_name;
// Ignore all non-directories
if (entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN) {
continue;
}
// The RedHat kernel hides threads with a dot. // The RedHat kernel hides threads with a dot.
// I believe this is non-standard. // I believe this is non-standard.