View | Details | Raw Unified | Return to bug 194450
Collapse All | Expand All

(-)Makefile (-4 / +5 lines)
Lines 2-15 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	htop
4
PORTNAME=	htop
5
PORTVERSION=	1.0.2
5
PORTVERSION=	1.0.3
6
PORTREVISION=	1
7
CATEGORIES=	sysutils
6
CATEGORIES=	sysutils
8
MASTER_SITES=	SF
7
MASTER_SITES=	http://hisham.hm/htop/releases/${PORTVERSION}/
9
8
10
MAINTAINER=	gaod@hychen.org
9
MAINTAINER=	gaod@hychen.org
11
COMMENT=	Better top(1) - interactive process viewer
10
COMMENT=	Better top(1) - interactive process viewer
12
11
12
LICENSE=	GPLv2
13
13
OPTIONS_DEFINE=	LSOF
14
OPTIONS_DEFINE=	LSOF
14
OPTIONS_DEFAULT=LSOF
15
OPTIONS_DEFAULT=LSOF
15
16
Lines 20-26 Link Here
20
LIBS+=		-L${LOCALBASE}/lib -lexecinfo
21
LIBS+=		-L${LOCALBASE}/lib -lexecinfo
21
22
22
CONFIGURE_ARGS=	--with-proc=/compat/linux/proc --enable-unicode
23
CONFIGURE_ARGS=	--with-proc=/compat/linux/proc --enable-unicode
23
USES=		ncurses libtool execinfo
24
USES=		execinfo libtool ncurses
24
USE_AUTOTOOLS=	autoconf aclocal automake
25
USE_AUTOTOOLS=	autoconf aclocal automake
25
ACLOCAL_ARGS=	-I ${ACLOCAL_DIR}
26
ACLOCAL_ARGS=	-I ${ACLOCAL_DIR}
26
27
(-)distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (htop-1.0.2.tar.gz) = ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1
1
SHA256 (htop-1.0.3.tar.gz) = 055c57927f75847fdc222b5258b079a9542811a9dcf5421c615c7e17f55d1829
2
SIZE (htop-1.0.2.tar.gz) = 388499
2
SIZE (htop-1.0.3.tar.gz) = 399306
(-)files/patch-Process.h (-3 / +3 lines)
Lines 1-6 Link Here
1
--- Process.h.orig	2013-04-21 03:34:39.000000000 +0800
1
--- Process.h.orig	2014-10-19 02:06:35.000000000 +0800
2
+++ Process.h	2013-04-21 03:34:49.000000000 +0800
2
+++ Process.h	2014-10-19 02:06:49.000000000 +0800
3
@@ -179,11 +179,11 @@
3
@@ -201,11 +201,11 @@
4
 bool Process_setPriority(Process* this, int priority);
4
 bool Process_setPriority(Process* this, int priority);
5
 
5
 
6
 bool Process_changePriorityBy(Process* this, size_t delta);
6
 bool Process_changePriorityBy(Process* this, size_t delta);
(-)files/patch-ProcessList.c (-78 / +5 lines)
Lines 1-84 Link Here
1
--- ProcessList.c.orig	2013-04-21 03:39:12.000000000 +0800
1
--- ProcessList.c.orig	2014-10-19 02:09:17.000000000 +0800
2
+++ ProcessList.c	2013-04-21 03:41:41.000000000 +0800
2
+++ ProcessList.c	2014-10-19 02:11:07.000000000 +0800
3
@@ -25,6 +25,19 @@
3
@@ -804,8 +804,6 @@
4
 #include <time.h>
5
 #include <assert.h>
6
 
7
+#ifndef PAGE_SIZE
8
+#define PAGE_SIZE sysconf(_SC_PAGESIZE)
9
+#endif
10
+
11
+#ifdef __FreeBSD__
12
+#define KB 1024
13
+#define SYSCTLBYNAME(name, var, len) sysctlbyname(name, &(var), &(len), NULL, 0)
14
+#include <kvm.h>
15
+#include <paths.h>
16
+#include <fcntl.h>
17
+#include <sys/sysctl.h>
18
+#endif
19
+
20
 /*{
21
 #include "Vector.h"
22
 #include "Hashtable.h"
23
@@ -685,7 +698,7 @@
24
       unsigned long long int lasttimes = (process->utime + process->stime);
4
       unsigned long long int lasttimes = (process->utime + process->stime);
25
       if (! ProcessList_readStatFile(process, dirname, name, command))
5
       if (! ProcessList_readStatFile(process, dirname, name, command))
26
          goto errorReadingProcess;
6
          goto errorReadingProcess;
27
-      Process_updateIOPriority(process);
7
-      if (this->flags & PROCESS_FLAG_IOPRIO)
28
+//      Process_updateIOPriority(process);
8
-         Process_updateIOPriority(process);
29
       float percent_cpu = (process->utime + process->stime - lasttimes) / period * 100.0;
9
       float percent_cpu = (process->utime + process->stime - lasttimes) / period * 100.0;
30
       process->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0);
10
       process->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0);
31
       if (isnan(process->percent_cpu)) process->percent_cpu = 0.0;
11
       if (isnan(process->percent_cpu)) process->percent_cpu = 0.0;
32
@@ -764,13 +777,15 @@
33
 
34
 void ProcessList_scan(ProcessList* this) {
35
    unsigned long long int usertime, nicetime, systemtime, systemalltime, idlealltime, idletime, totaltime, virtalltime;
36
-   unsigned long long int swapFree = 0;
37
+   int cpus = this->cpuCount;
38
+   FILE* file = NULL;
39
 
40
-   FILE* file = fopen(PROCMEMINFOFILE, "r");
41
+   #ifndef __FreeBSD__
42
+   unsigned long long int swapFree = 0;
43
+   file = fopen(PROCMEMINFOFILE, "r");
44
    if (file == NULL) {
45
       CRT_fatalError("Cannot open " PROCMEMINFOFILE);
46
    }
47
-   int cpus = this->cpuCount;
48
    {
49
       char buffer[128];
50
       while (fgets(buffer, 128, file)) {
51
@@ -805,6 +820,33 @@
52
    this->usedMem = this->totalMem - this->freeMem;
53
    this->usedSwap = this->totalSwap - swapFree;
54
    fclose(file);
55
+   #endif
56
+
57
+   #ifdef __FreeBSD__
58
+   kvm_t *kd = NULL;
59
+   struct kvm_swap kvmswapinfo[1];
60
+   size_t len = 0;
61
+
62
+   kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, NULL);
63
+   assert(kd != NULL);
64
+   kvm_getswapinfo(kd, kvmswapinfo, 1, 0);
65
+   this->totalSwap = kvmswapinfo[0].ksw_total * (PAGE_SIZE / KB);
66
+   this->usedSwap = kvmswapinfo[0].ksw_used * (PAGE_SIZE / KB);
67
+   kvm_close(kd);
68
+   len = sizeof(this->totalMem);
69
+   SYSCTLBYNAME("vm.stats.vm.v_page_count", this->totalMem, len);
70
+   this->totalMem *= PAGE_SIZE / KB;
71
+   len = sizeof(this->cachedMem);
72
+   SYSCTLBYNAME("vm.stats.vm.v_cache_count", this->cachedMem, len);
73
+   this->cachedMem *= PAGE_SIZE / KB;
74
+   len = sizeof(this->buffersMem);
75
+   SYSCTLBYNAME("vfs.bufspace", this->buffersMem, len);
76
+   this->buffersMem /= KB;
77
+   len = sizeof(this->usedMem);
78
+   SYSCTLBYNAME("vm.stats.vm.v_active_count", this->usedMem, len);
79
+   this->usedMem = this->usedMem * PAGE_SIZE / KB + this->cachedMem + this->buffersMem;
80
+   this->freeMem = this->totalMem - this->usedMem;
81
+   #endif
82
 
83
    file = fopen(PROCSTATFILE, "r");
84
    if (file == NULL) {
(-)files/patch-configure.ac (-4 / +4 lines)
Lines 1-5 Link Here
1
--- configure.ac.orig	2011-12-26 23:46:57.000000000 +0200
1
--- configure.ac.orig	2014-10-19 02:12:28.000000000 +0800
2
+++ configure.ac	2012-05-16 17:39:50.000000000 +0300
2
+++ configure.ac	2014-10-19 02:14:19.000000000 +0800
3
@@ -23,11 +23,12 @@
3
@@ -23,11 +23,12 @@
4
 
4
 
5
 # Checks for libraries.
5
 # Checks for libraries.
Lines 9-16 Link Here
9
 # Checks for header files.
9
 # Checks for header files.
10
 AC_HEADER_DIRENT
10
 AC_HEADER_DIRENT
11
 AC_HEADER_STDC
11
 AC_HEADER_STDC
12
-AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h curses.h],[:],[
12
-AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
13
+AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h curses.h kvm.h paths.h fcntl.h sys/sysctl.h],[:],[
13
+AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h kvm.h paths.h fcntl.h sys/sysctl.h],[:],[
14
   missing_headers="$missing_headers $ac_header"
14
   missing_headers="$missing_headers $ac_header"
15
 ])
15
 ])
16
 AC_CHECK_HEADERS([execinfo.h],[:],[:])
16
 AC_CHECK_HEADERS([execinfo.h],[:],[:])
(-)files/patch-htop.c (-32 / +30 lines)
Lines 1-38 Link Here
1
--- htop.c.orig	2012-10-05 07:55:31.000000000 +0800
1
--- htop.c.orig	2014-10-19 02:15:19.000000000 +0800
2
+++ htop.c	2013-04-21 03:47:54.882373049 +0800
2
+++ htop.c	2014-10-19 02:17:10.000000000 +0800
3
@@ -126,7 +126,7 @@
3
@@ -96,7 +96,6 @@
4
    mvaddstr(13, 0, "  Space: tag processes                      F: cursor follows process");
5
    mvaddstr(14, 0, "      U: untag all processes              + -: expand/collapse tree");
6
    mvaddstr(15, 0, "   F9 k: kill process/tagged processes  P M T: sort by CPU%, MEM% or TIME");
7
-   mvaddstr(16, 0, "   ] F7: higher priority (root only)        i: set IO priority");
8
+   mvaddstr(16, 0, "   ] F7: higher priority (root only)");
9
    mvaddstr(17, 0, "   [ F8: lower priority (+ nice)            I: invert sort order");
10
 #if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
4
 #if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
11
    if (pl->cpuCount > 1)
5
    { .key = "      a: ", .info = "set CPU affinity" },
12
@@ -146,7 +146,7 @@
6
 #endif
13
    mvaddstr(13, 0, "  Space"); mvaddstr(13,40, "    F");
7
-   { .key = "      i: ", .info = "set IO prority" },
14
    mvaddstr(14, 0, "      U"); mvaddstr(14,40, "  + -");
8
    { .key = "      l: ", .info = "list open files with lsof" },
15
    mvaddstr(15, 0, "   F9 k"); mvaddstr(15,40, "P M T");
9
    { .key = "      s: ", .info = "trace syscalls with strace" },
16
-   mvaddstr(16, 0, "   ] F7"); mvaddstr(16,40, "    i");
10
    { .key = "         ", .info = "" },
17
+   mvaddstr(16, 0, "   ] F7");
11
@@ -856,25 +855,6 @@
18
    mvaddstr(17, 0, "   [ F8"); mvaddstr(17,40, "    I");
12
          }
19
                                mvaddstr(18,40, " F6 >");
20
 #if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
21
@@ -850,7 +850,7 @@
22
          ((Object*)sortPanel)->delete((Object*)sortPanel);
23
          refreshTimeout = 0;
24
          break;
13
          break;
14
       }
15
-      case 'i':
16
-      {
17
-         Process* p = (Process*) Panel_getSelected(panel);
18
-         if (!p) break;
19
-         IOPriority ioprio = p->ioPriority;
20
-         Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
21
-         const char* fuFunctions[] = {"Set    ", "Cancel ", NULL};
22
-         void* set = pickFromVector(panel, ioprioPanel, 21, headerHeight, fuFunctions, defaultBar, header);
23
-         if (set) {
24
-            IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
25
-            bool ok = foreachProcess(panel, (ForeachProcessFn) Process_setIOPriority, (size_t) ioprio, NULL);
26
-            if (!ok)
27
-               beep();
28
-         }
29
-         Panel_delete((Object*)ioprioPanel);
30
-         ProcessList_printHeader(pl, Panel_getHeader(panel));
31
-         refreshTimeout = 0;
32
-         break;
25
-      }
33
-      }
26
+      }/*
27
       case 'i':
28
       {
29
          Process* p = (Process*) Panel_getSelected(panel);
30
@@ -869,7 +869,7 @@
31
          ProcessList_printHeader(pl, Panel_getHeader(panel));
32
          refreshTimeout = 0;
33
          break;
34
-      }
35
+      }*/
36
       case 'I':
34
       case 'I':
37
       {
35
       {
38
          refreshTimeout = 0;
36
          refreshTimeout = 0;

Return to bug 194450