]> granicus.if.org Git - sysstat/commitdiff
pidstat: Don't stop if gtime and cgtime fields are unavailable
authorSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 12 Mar 2015 20:39:58 +0000 (21:39 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 12 Mar 2015 20:39:58 +0000 (21:39 +0100)
With some old 2.6 kernels, fields "gtime" and "cgtime" (which are
expected to be read from /proc/#/stat file) may not be present.
pidstat used to stop should this case happens.
Fix this since these fields are not mandatory for pidstat to display its
statistics.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
pidstat.c

index 6bbdc26d386f1797285fa1c3511739596eae43a8..7a75254bacb7cc25f2d101fa729bc350e4955c06 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -356,9 +356,14 @@ int read_proc_pid_stat(unsigned int pid, struct pid_stats *pst,
                    &pst->priority, &pst->policy,
                    &pst->blkio_swapin_delays, &pst->gtime, &pst->cgtime);
 
-       if (rc < 17)
+       if (rc < 15)
                return 1;
 
+       if (rc < 17) {
+               /* gtime and cgtime fields are unavailable in file */
+               pst->gtime = pst->cgtime = 0;
+       }
+
        /* Convert to kB */
        pst->vsz >>= 10;
        pst->rss = PG_TO_KB(pst->rss);