]> granicus.if.org Git - sysstat/commitdiff
Added realloc_pid() also to the read_task_stats() fn
authorPeter Schiffer <pschiffe@redhat.com>
Fri, 28 Aug 2015 11:03:01 +0000 (13:03 +0200)
committerPeter Schiffer <pschiffe@redhat.com>
Fri, 28 Aug 2015 11:03:01 +0000 (13:03 +0200)
pidstat.c

index a8bf57142de9e3f1aea8bc2f85a6fe4c9f25475a..f54c1daed51d82a063daf7c213bd703a82f26903 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -881,23 +881,22 @@ void read_task_stats(int curr, unsigned int pid, unsigned int *index)
        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);
 }