aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/wmtop
diff options
context:
space:
mode:
authorclsung <clsung@FreeBSD.org>2005-03-04 00:05:22 +0800
committerclsung <clsung@FreeBSD.org>2005-03-04 00:05:22 +0800
commit350390d787bcf237aa3933f1a03c54341a6edcc6 (patch)
tree0153441491923ef00d1594e73b33e9b6531ef640 /sysutils/wmtop
parent915210026c210c7348b8f628eebc97dfe6a5b95e (diff)
downloadfreebsd-ports-graphics-350390d787bcf237aa3933f1a03c54341a6edcc6.tar.gz
freebsd-ports-graphics-350390d787bcf237aa3933f1a03c54341a6edcc6.tar.zst
freebsd-ports-graphics-350390d787bcf237aa3933f1a03c54341a6edcc6.zip
- wmtop gets process information via procfs, but FreeBSD 5.x
doesn't mount it by default. The 5.x users won't see any process shown by wmtop unless they mount procfs for some reasons. PR: 78243 Submitted by: Yi-Hsuan Hsin <mhsin AT mhsin dot org>
Diffstat (limited to 'sysutils/wmtop')
-rw-r--r--sysutils/wmtop/Makefile17
-rw-r--r--sysutils/wmtop/files/patch-la120
-rw-r--r--sysutils/wmtop/pkg-plist6
3 files changed, 135 insertions, 8 deletions
diff --git a/sysutils/wmtop/Makefile b/sysutils/wmtop/Makefile
index 4d8fd22cb17..ea32efc011b 100644
--- a/sysutils/wmtop/Makefile
+++ b/sysutils/wmtop/Makefile
@@ -17,13 +17,26 @@ COMMENT= Windowmaker dock app to display top 3 CPU consuming processes
USE_X_PREFIX= yes
USE_XPM= yes
ALL_TARGET= freebsd
+USE_REINPLACE= yes
MAN1= wmtop.1
+.if !defined(NOPORTDOCS)
+PORTDOCS= BUGS CHANGES COPYING README TODO
+.endif
+
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} >= 500000
+post-patch:
+ ${REINPLACE_CMD} -e 's/^\(LIBS.*\)/\1 -lkvm/' ${WRKSRC}/Makefile
+ ${REINPLACE_CMD} -e 's/^\(FLAGS.*\)/\1 -DNO_PROCFS/' ${WRKSRC}/Makefile
+.endif
+
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/wmtop ${PREFIX}/bin/
${INSTALL_MAN} ${WRKSRC}/wmtop.1 ${PREFIX}/man/man1
-.ifndef(NOPORTDOCS)
+.if !defined(NOPORTDOCS)
@${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m 555 \
${PREFIX}/share/doc/${PORTNAME}
.for file in BUGS CHANGES COPYING README TODO
@@ -32,4 +45,4 @@ do-install:
.endfor
.endif # !NOPORTDOCS
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff --git a/sysutils/wmtop/files/patch-la b/sysutils/wmtop/files/patch-la
new file mode 100644
index 00000000000..7ce361ad404
--- /dev/null
+++ b/sysutils/wmtop/files/patch-la
@@ -0,0 +1,120 @@
+--- wmtop.c.orig Wed Mar 7 05:30:56 2001
++++ wmtop.c Fri Feb 25 22:34:36 2005
+@@ -70,6 +70,13 @@
+ #include "xpm/wmtop-neon2.xpm"
+ #include "xpm/wmtop-rainbow.xpm"
+
++#ifdef NO_PROCFS
++#include <kvm.h>
++#include <sys/sysctl.h>
++#include <sys/user.h>
++#include <sys/resource.h>
++#endif
++
+ /******************************************/
+ /* Defines */
+ /******************************************/
+@@ -191,6 +198,9 @@
+ int rss;
+ int time_stamp;
+ int counted;
++#ifdef NO_PROCFS
++ struct kinfo_proc *kp;
++#endif
+ };
+
+ /******************************************/
+@@ -455,17 +465,19 @@
+ * Anyone hoping to port wmtop should look here first.
+ */
+ int process_parse_procfs(struct process *process) {
++#if !defined(NO_PROCFS)
+ char line[WMTOP_BUFLENGTH],filename[WMTOP_BUFLENGTH],procname[WMTOP_BUFLENGTH];
+ int ps;
+ struct stat sbuf;
+- int user_time,kernel_time;
+ int rc;
++#endif
++ int user_time,kernel_time;
+ #if defined(LINUX)
+ char *r,*q;
+ char deparenthesised_name[WMTOP_BUFLENGTH];
+ int endl;
+ #endif /* defined(LINUX) */
+-#if defined(FREEBSD)
++#if defined(FREEBSD) && !defined(NO_PROCFS)
+ int us,um,ks,km;
+ #endif /* defined(FREEBSD) */
+
+@@ -473,6 +485,15 @@
+ assert(process->id==0x0badfeed);
+ #endif /* defined(PARANOID) */
+
++#if defined(NO_PROCFS)
++#define GETV(u) ((u).tv_sec * 1000 + (u).tv_usec / 1000)
++ process->time_stamp = g_time;
++ if(process->name)
++ wmtop_free(process->name);
++ process->name = wmtop_strdup(process->kp->ki_comm);
++ process->user_time = GETV(process->kp->ki_rusage.ru_utime);
++ process->kernel_time = GETV(process->kp->ki_rusage.ru_stime);
++#else
+ sprintf(filename,PROCFS_TEMPLATE,process->pid);
+
+ /*
+@@ -582,6 +603,7 @@
+ process->user_time = us*1000+um/1000;
+ process->kernel_time = ks*1000+km/1000;
+ #endif /* defined(FREEBSD) */
++#endif /* defined(NO_PROCFS) */
+
+ process->rss *= getpagesize();
+
+@@ -607,6 +629,39 @@
+ /******************************************/
+
+ int update_process_table() {
++#if defined(NO_PROCFS)
++ kvm_t *kd;
++ int n;
++ struct kinfo_proc *p;
++
++ if((kd = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "wmtop")) == NULL)
++ return 1;
++
++ if((p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n)) == NULL)
++ return 1;
++
++ for(; n > 0; n --, p ++)
++ {
++ char **argv;
++ struct process *pp;
++
++ if((argv = kvm_getargv(kd, p, 0)) == NULL ||
++ argv[0] == NULL)
++ continue;
++
++ pp = find_process(p->ki_pid);
++ if(!pp)
++ pp = new_process(p->ki_pid);
++
++ pp->kp = p;
++ calculate_cpu(pp);
++ }
++
++ if(kvm_close(kd) != 0)
++ return 1;
++
++ return 0;
++#else
+ DIR *dir;
+ struct dirent *entry;
+
+@@ -640,6 +695,7 @@
+ closedir(dir);
+
+ return 0;
++#endif /* defined(NO_PROCFS) */
+ }
+
+ /******************************************/
diff --git a/sysutils/wmtop/pkg-plist b/sysutils/wmtop/pkg-plist
index ba94c0180d1..4aa7c47bc87 100644
--- a/sysutils/wmtop/pkg-plist
+++ b/sysutils/wmtop/pkg-plist
@@ -1,7 +1 @@
bin/wmtop
-%%PORTDOCS%%share/doc/wmtop/BUGS
-%%PORTDOCS%%share/doc/wmtop/CHANGES
-%%PORTDOCS%%share/doc/wmtop/COPYING
-%%PORTDOCS%%share/doc/wmtop/README
-%%PORTDOCS%%share/doc/wmtop/TODO
-%%PORTDOCS%%@dirrm share/doc/wmtop