if ((dir = opendir(filename)) == NULL)
return;
- while (*index < pid_nr) {
+ while ((drp = readdir(dir)) != NULL) {
+ if (!isdigit(drp->d_name[0])) {
+ continue;
+ }
- while ((drp = readdir(dir)) != NULL) {
- if (isdigit(drp->d_name[0]))
- break;
+ pst = st_pid_list[curr] + (*index)++;
+ if (read_pid_stats(atoi(drp->d_name), pst, &thr_nr, pid)) {
+ /* Thread no longer exists */
+ pst->pid = 0;
}
- if (drp) {
- pst = st_pid_list[curr] + (*index)++;
- if (read_pid_stats(atoi(drp->d_name), pst, &thr_nr, pid)) {
- /* Thread no longer exists */
- pst->pid = 0;
- }
+ if (*index >= pid_nr) {
+ realloc_pid();
}
- else
- break;
}
+
closedir(dir);
}