From 333a1bb6b8eab9dd01e2ead15a49b1accb492e42 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 14 Feb 2021 00:00:00 -0600 Subject: [PATCH] library: tweak logic for /proc not mounted, api Since 'procps_uptime' will access the /proc filesystem the '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 --- proc/pids.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proc/pids.c b/proc/pids.c index e99abdd1..b619b0e7 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -1192,10 +1192,11 @@ 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); - p->boot_seconds = uptime_secs; + + // 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();