library: tweak logic for /proc not mounted, <pids> api

Since 'procps_uptime' will access the /proc filesystem
the <pids> 'new' guy should should protect against the
possibility /proc isn't mounted when 'boot_seconds' is
established. A zero is better than the negative value.

[ the only distortion would be to PIDS_TIME_ELAPSED. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2021-02-14 00:00:00 -06:00 committed by Craig Small
parent 0b689adde0
commit 333a1bb6b8

View File

@ -1192,9 +1192,10 @@ PROCPS_EXPORT int procps_pids_new (
pgsz = getpagesize();
while (pgsz > 1024) { pgsz >>= 1; p->pgs2k_shift++; }
p->hertz = procps_hertz_get();
procps_uptime(&uptime_secs, NULL);
// in case 'fatal_proc_unmounted' wasn't called and /proc isn't mounted
if (0 >= procps_uptime(&uptime_secs, NULL))
p->boot_seconds = uptime_secs;
numa_init();