From 8c82a38002ce09db2a0b83dab8b598cf1ab0596c Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:01:17 +0200 Subject: Imported Upstream version 2.0.1 --- linux/LinuxProcess.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'linux/LinuxProcess.c') diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index c6c3112..43b5e38 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -268,13 +268,20 @@ io_priority = (cpu_nice + 20) / 5. -- From ionice(1) man page #define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority) IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) { - IOPriority ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid); + IOPriority ioprio = 0; +// Other OSes masquerading as Linux (NetBSD?) don't have this syscall +#ifdef SYS_ioprio_get + ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid); +#endif this->ioPriority = ioprio; return ioprio; } bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) { +// Other OSes masquerading as Linux (NetBSD?) don't have this syscall +#ifdef SYS_ioprio_set syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio); +#endif return (LinuxProcess_updateIOPriority(this) == ioprio); } @@ -306,7 +313,12 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) case CNCLWB: Process_colorNumber(str, lp->io_cancelled_write_bytes, coloring); return; 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: Process_outputRate(str, buffer, n, lp->io_rate_read_bps + 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; + Process_outputRate(str, buffer, n, totalRate, coloring); return; + } #endif #ifdef HAVE_OPENVZ case CTID: snprintf(buffer, n, "%7u ", lp->ctid); break; -- cgit v1.2.3