diff --git a/proc/meminfo.c b/proc/meminfo.c index 0882a493..53d4e46f 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -749,6 +749,14 @@ PROCPS_EXPORT int procps_meminfo_new ( return rc; } + /* do a priming read here for the following potential benefits: | + 1) ensure there will be no problems with subsequent access | + 2) make delta results potentially useful, even if 1st time | */ + if ((rc = meminfo_read_failed(p))) { + procps_meminfo_unref(&p); + return rc; + } + *info = p; return 0; } // end: procps_meminfo_new diff --git a/proc/stat.c b/proc/stat.c index d81f817e..141873c7 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -828,6 +828,7 @@ PROCPS_EXPORT int procps_stat_new ( struct stat_info **info) { struct stat_info *p; + int rc; if (info == NULL || *info != NULL) return -EINVAL; @@ -869,6 +870,14 @@ PROCPS_EXPORT int procps_stat_new ( #endif #endif + /* do a priming read here for the following potential benefits: | + 1) ensure there will be no problems with subsequent access | + 2) make delta results potentially useful, even if 1st time | */ + if ((rc = stat_read_failed(p))) { + procps_stat_unref(&p); + return rc; + } + *info = p; return 0; } // end :procps_stat_new diff --git a/proc/vmstat.c b/proc/vmstat.c index 62d480eb..71b374b5 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -1133,6 +1133,14 @@ PROCPS_EXPORT int procps_vmstat_new ( return rc; } + /* do a priming read here for the following potential benefits: | + 1) ensure there will be no problems with subsequent access | + 2) make delta results potentially useful, even if 1st time | */ + if ((rc = vmstat_read_failed(p))) { + procps_vmstat_unref(&p); + return rc; + } + *info = p; return 0; } // end: procps_vmstat_new