From: Jim Warner Date: Sun, 27 Apr 2014 05:00:00 +0000 (-0500) Subject: top: avoid a 'nan' when the delay interval is very low X-Git-Tag: v3.3.10~96^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe37ad15cd394af021af7a3e5ad11bad70af4bfd;p=procps-ng top: avoid a 'nan' when the delay interval is very low The granularity of /proc/uptime is fixed at hundredths of a second. And, since we can cycle faster than that, we are exposed to 'nan' when calculating elapsed time. This commit will protect us from that outcome when the delay interval has been set to an extremely low value. Signed-off-by: Jim Warner --- diff --git a/top/top.c b/top/top.c index 0428496f..0ae53885 100644 --- a/top/top.c +++ b/top/top.c @@ -2525,6 +2525,7 @@ static void procs_hlp (proc_t *this) { uptime(&uptime_cur, NULL); et = uptime_cur - uptime_sav; + if (et < 0.01) et = 0.005; uptime_sav = uptime_cur; // if in Solaris mode, adjust our scaling for all cpus