# This patch introduce --enable-iopriority to define HAVE_IOPRIORITY # The default is determined checking if SYS_ioprio_get is available or not # https://bugs.gentoo.org/show_bug.cgi?id=442622 --- a/Process.c +++ b/Process.c @@ -517,6 +517,7 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel #ifdef HAVE_CGROUP case CGROUP: snprintf(buffer, n, "%-10s ", this->cgroup); break; #endif + #ifdef HAVE_IOPRIORITY case IO_PRIORITY: { int klass = IOPriority_class(this->ioPriority); if (klass == IOPRIO_CLASS_NONE) { @@ -535,6 +536,7 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel } break; } + #endif default: snprintf(buffer, n, "- "); } @@ -603,6 +605,7 @@ bool Process_changePriorityBy(Process* this, size_t delta) { return Process_setPriority(this, this->nice + delta); } +#ifdef HAVE_IOPRIORITY IOPriority Process_updateIOPriority(Process* this) { IOPriority ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->pid); this->ioPriority = ioprio; @@ -613,6 +616,7 @@ bool Process_setIOPriority(Process* this, IOPriority ioprio) { syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->pid, ioprio); return (Process_updateIOPriority(this) == ioprio); } +#endif /* [1] Note that before kernel 2.6.26 a process that has not asked for @@ -781,8 +785,10 @@ int Process_compare(const void* v1, const void* v2) { case CGROUP: return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : ""); #endif + #ifdef HAVE_IOPRIORITY case IO_PRIORITY: return Process_effectiveIOPriority(p1) - Process_effectiveIOPriority(p2); + #endif default: return (p1->pid - p2->pid); } --- a/ProcessList.c +++ b/ProcessList.c @@ -685,7 +685,9 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P unsigned long long int lasttimes = (process->utime + process->stime); if (! ProcessList_readStatFile(process, dirname, name, command)) goto errorReadingProcess; + #ifdef HAVE_IOPRIORITY Process_updateIOPriority(process); + #endif float percent_cpu = (process->utime + process->stime - lasttimes) / period * 100.0; process->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0); if (isnan(process->percent_cpu)) process->percent_cpu = 0.0; --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,12 @@ if test "x$enable_cgroup" = xyes; then AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.]) fi +AC_ARG_ENABLE(iopriority, [AC_HELP_STRING([--enable-iopriority], [enable IO priority support])], , + AC_CHECK_DECLS(SYS_ioprio_get, [enable_iopriority=yes], [enable_iopriority=no], [#include ])) +if test "x$enable_iopriority" = xyes; then + AC_DEFINE(HAVE_IOPRIORITY, 1, [Define if IO priority support enabled.]) +fi + AC_ARG_ENABLE(vserver, [AC_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no") if test "x$enable_vserver" = xyes; then AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.]) --- a/htop.c +++ b/htop.c @@ -851,6 +851,7 @@ int main(int argc, char** argv) { refreshTimeout = 0; break; } +#ifdef HAVE_IOPRIORITY case 'i': { Process* p = (Process*) Panel_getSelected(panel); @@ -870,6 +871,7 @@ int main(int argc, char** argv) { refreshTimeout = 0; break; } +#endif case 'I': { refreshTimeout = 0;