Skip to content

Commit b8369bf

Browse files
committed
pidstat: Don't stop if gtime and cgtime fields are unavailable
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 <[email protected]>
1 parent a16d460 commit b8369bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pidstat.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,14 @@ int read_proc_pid_stat(unsigned int pid, struct pid_stats *pst,
356356
&pst->priority, &pst->policy,
357357
&pst->blkio_swapin_delays, &pst->gtime, &pst->cgtime);
358358

359-
if (rc < 17)
359+
if (rc < 15)
360360
return 1;
361361

362+
if (rc < 17) {
363+
/* gtime and cgtime fields are unavailable in file */
364+
pst->gtime = pst->cgtime = 0;
365+
}
366+
362367
/* Convert to kB */
363368
pst->vsz >>= 10;
364369
pst->rss = PG_TO_KB(pst->rss);

0 commit comments

Comments
 (0)