[CP] fix file read error

This commit is contained in:
zhjc1124
2023-10-19 07:39:28 +00:00
committed by ob-robot
parent 763d2240d5
commit ee920752cb

View File

@ -408,14 +408,13 @@ static void print_all_thread(const char* desc)
struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
char *tid = entry->d_name;
if (tid[0] == '.')
continue; // pass . and ..
if (tid[0] != '.') { // pass . and ..
char path[256];
sprintf(path, "/proc/self/task/%s/comm", tid);
FILE *file = fopen(path, "r");
if (file == NULL) {
MPRINT("fail to print thread tid: %s", tid);
}
} else {
char name[256];
fgets(name, 256, file);
size_t len = strlen(name);
@ -426,6 +425,8 @@ static void print_all_thread(const char* desc)
fclose(file);
}
}
}
}
closedir(dir);
MPRINT("============= [%s] finish to show unstopped thread =============", desc);
}