From 35657208d7dc6262c477f5d9d5626dba5d8dc05c Mon Sep 17 00:00:00 2001 From: Hisham Date: Sun, 14 Feb 2016 12:05:35 -0200 Subject: [PATCH] Disable the syscall on systems that don't have it. Got a report in #397 that htop runs in NetBSD masquerading as Linux and using a compatibility /proc (like we used to in FreeBSD) and that it builds fine apart from this syscall. --- linux/LinuxProcess.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index c6c3112d..17790f65 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); }