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

(-)wmtop/Makefile (-2 / +15 lines)
Lines 17-29 Link Here
17
USE_X_PREFIX=	yes
17
USE_X_PREFIX=	yes
18
USE_XPM=	yes
18
USE_XPM=	yes
19
ALL_TARGET=	freebsd
19
ALL_TARGET=	freebsd
20
USE_REINPLACE=	yes
20
21
21
MAN1=		wmtop.1
22
MAN1=		wmtop.1
22
23
24
.if !defined(NOPORTDOCS)
25
PORTDOCS=	BUGS CHANGES COPYING README TODO
26
.endif
27
28
.include <bsd.port.pre.mk>
29
30
.if ${OSVERSION} >= 500000
31
post-patch:
32
	${REINPLACE_CMD} -e 's/^\(LIBS.*\)/\1 -lkvm/' ${WRKSRC}/Makefile
33
	${REINPLACE_CMD} -e 's/^\(FLAGS.*\)/\1 -DNO_PROCFS/' ${WRKSRC}/Makefile
34
.endif
35
23
do-install:
36
do-install:
24
	${INSTALL_PROGRAM} ${WRKSRC}/wmtop ${PREFIX}/bin/
37
	${INSTALL_PROGRAM} ${WRKSRC}/wmtop ${PREFIX}/bin/
25
	${INSTALL_MAN} ${WRKSRC}/wmtop.1 ${PREFIX}/man/man1
38
	${INSTALL_MAN} ${WRKSRC}/wmtop.1 ${PREFIX}/man/man1
26
.ifndef(NOPORTDOCS)
39
.if !defined(NOPORTDOCS)
27
	@${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m 555 \
40
	@${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m 555 \
28
		${PREFIX}/share/doc/${PORTNAME}
41
		${PREFIX}/share/doc/${PORTNAME}
29
.for file in BUGS CHANGES COPYING README TODO
42
.for file in BUGS CHANGES COPYING README TODO
Lines 32-35 Link Here
32
.endfor
45
.endfor
33
.endif # !NOPORTDOCS
46
.endif # !NOPORTDOCS
34
47
35
.include <bsd.port.mk>
48
.include <bsd.port.post.mk>
(-)wmtop/files/patch-la (+120 lines)
Line 0 Link Here
1
--- wmtop.c.orig	Wed Mar  7 05:30:56 2001
2
+++ wmtop.c	Fri Feb 25 22:34:36 2005
3
@@ -70,6 +70,13 @@
4
 #include "xpm/wmtop-neon2.xpm"
5
 #include "xpm/wmtop-rainbow.xpm"
6
 
7
+#ifdef NO_PROCFS
8
+#include <kvm.h>
9
+#include <sys/sysctl.h>
10
+#include <sys/user.h>
11
+#include <sys/resource.h>
12
+#endif
13
+
14
 /******************************************/
15
 /* Defines                                */
16
 /******************************************/
17
@@ -191,6 +198,9 @@
18
     int rss;
19
     int time_stamp;
20
     int counted;
21
+#ifdef NO_PROCFS
22
+    struct kinfo_proc *kp;
23
+#endif
24
 };
25
 
26
 /******************************************/
27
@@ -455,17 +465,19 @@
28
  * Anyone hoping to port wmtop should look here first.
29
  */
30
 int process_parse_procfs(struct process *process) {
31
+#if !defined(NO_PROCFS)
32
     char line[WMTOP_BUFLENGTH],filename[WMTOP_BUFLENGTH],procname[WMTOP_BUFLENGTH];
33
     int ps;
34
     struct stat sbuf;
35
-    int user_time,kernel_time;
36
     int rc;
37
+#endif
38
+    int user_time,kernel_time;
39
 #if defined(LINUX)
40
     char *r,*q;
41
     char deparenthesised_name[WMTOP_BUFLENGTH];
42
 		int endl;
43
 #endif /* defined(LINUX) */
44
-#if defined(FREEBSD)
45
+#if defined(FREEBSD) && !defined(NO_PROCFS)
46
     int us,um,ks,km;
47
 #endif /* defined(FREEBSD) */
48
 
49
@@ -473,6 +485,15 @@
50
     assert(process->id==0x0badfeed);
51
 #endif /* defined(PARANOID) */
52
 
53
+#if defined(NO_PROCFS)
54
+#define GETV(u) ((u).tv_sec * 1000 + (u).tv_usec / 1000)
55
+    process->time_stamp = g_time;
56
+    if(process->name)
57
+        wmtop_free(process->name);
58
+    process->name = wmtop_strdup(process->kp->ki_comm);
59
+    process->user_time = GETV(process->kp->ki_rusage.ru_utime);
60
+    process->kernel_time = GETV(process->kp->ki_rusage.ru_stime);
61
+#else
62
     sprintf(filename,PROCFS_TEMPLATE,process->pid);
63
 
64
     /*
65
@@ -582,6 +603,7 @@
66
     process->user_time = us*1000+um/1000;
67
     process->kernel_time = ks*1000+km/1000;
68
 #endif /* defined(FREEBSD) */
69
+#endif /* defined(NO_PROCFS) */
70
 
71
     process->rss *= getpagesize();
72
 
73
@@ -607,6 +629,39 @@
74
 /******************************************/
75
 
76
 int update_process_table() {
77
+#if defined(NO_PROCFS)
78
+    kvm_t *kd;
79
+    int n;
80
+    struct kinfo_proc *p;
81
+
82
+    if((kd = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "wmtop")) == NULL)
83
+        return 1;
84
+
85
+    if((p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n)) == NULL)
86
+        return 1;
87
+
88
+    for(; n > 0; n --, p ++)
89
+    {
90
+      char **argv;
91
+      struct process *pp;
92
+
93
+      if((argv = kvm_getargv(kd, p, 0)) == NULL ||
94
+         argv[0] == NULL)
95
+        continue;
96
+
97
+      pp = find_process(p->ki_pid);
98
+      if(!pp)
99
+          pp = new_process(p->ki_pid);
100
+
101
+      pp->kp = p;
102
+      calculate_cpu(pp);
103
+    }
104
+
105
+    if(kvm_close(kd) != 0)
106
+        return 1;
107
+
108
+    return 0;
109
+#else
110
     DIR *dir;
111
     struct dirent *entry;
112
 
113
@@ -640,6 +695,7 @@
114
     closedir(dir);
115
 
116
     return 0;
117
+#endif /* defined(NO_PROCFS) */
118
 }
119
 
120
 /******************************************/
(-)wmtop/pkg-plist (-6 lines)
Lines 1-7 Link Here
1
bin/wmtop
1
bin/wmtop
2
%%PORTDOCS%%share/doc/wmtop/BUGS
3
%%PORTDOCS%%share/doc/wmtop/CHANGES
4
%%PORTDOCS%%share/doc/wmtop/COPYING
5
%%PORTDOCS%%share/doc/wmtop/README
6
%%PORTDOCS%%share/doc/wmtop/TODO
7
%%PORTDOCS%%@dirrm share/doc/wmtop

Return to bug 78243