mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Update IO rate display to use NAN on error
This commit is contained in:
parent
47e2cefe02
commit
29ec115143
@ -219,7 +219,7 @@ void Process_outputRate(RichString* str, char* buffer, int n, double rate, int c
|
||||
largeNumberColor = CRT_colors[PROCESS];
|
||||
processMegabytesColor = CRT_colors[PROCESS];
|
||||
}
|
||||
if (rate == -1) {
|
||||
if (isnan(rate)) {
|
||||
int len = snprintf(buffer, n, " no perm ");
|
||||
RichString_appendn(str, CRT_colors[PROCESS_SHADOW], buffer, len);
|
||||
} else if (rate < ONE_K) {
|
||||
|
@ -17,6 +17,7 @@ in the source distribution for its full text.
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
/* semi-global */
|
||||
long long btime;
|
||||
@ -237,9 +238,15 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
|
||||
case IO_READ_RATE: Process_outputRate(str, buffer, n, lp->io_rate_read_bps, coloring); return;
|
||||
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
|
||||
case IO_RATE: {
|
||||
double totalRate = (lp->io_rate_read_bps != -1)
|
||||
? (lp->io_rate_read_bps + lp->io_rate_write_bps)
|
||||
: -1;
|
||||
double totalRate = NAN;
|
||||
if(!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
|
||||
totalRate = lp->io_rate_read_bps + lp->io_rate_write_bps;
|
||||
else if(!isnan(lp->io_rate_read_bps))
|
||||
totalRate = lp->io_rate_read_bps;
|
||||
else if(!isnan(lp->io_rate_write_bps))
|
||||
totalRate = lp->io_rate_write_bps;
|
||||
else
|
||||
totalRate = NAN;
|
||||
Process_outputRate(str, buffer, n, totalRate, coloring); return;
|
||||
}
|
||||
#endif
|
||||
|
@ -331,8 +331,8 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
||||
xSnprintf(filename, MAX_NAME, "%s/%s/io", dirname, name);
|
||||
int fd = open(filename, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
process->io_rate_read_bps = -1;
|
||||
process->io_rate_write_bps = -1;
|
||||
process->io_rate_read_bps = NAN;
|
||||
process->io_rate_write_bps = NAN;
|
||||
process->io_rchar = -1LL;
|
||||
process->io_wchar = -1LL;
|
||||
process->io_syscr = -1LL;
|
||||
|
Loading…
Reference in New Issue
Block a user