diff options
author | ehaupt <ehaupt@FreeBSD.org> | 2008-02-27 18:12:56 +0800 |
---|---|---|
committer | ehaupt <ehaupt@FreeBSD.org> | 2008-02-27 18:12:56 +0800 |
commit | 7e6b50eb965c8dc9ec31e59411bc3464b8f639af (patch) | |
tree | 1db5154511947a785cb679000193169f4931723a | |
parent | ded97f37edc69f81a21bf0e92521e7c6f0d5fa2b (diff) | |
download | freebsd-ports-gnome-7e6b50eb965c8dc9ec31e59411bc3464b8f639af.tar.gz freebsd-ports-gnome-7e6b50eb965c8dc9ec31e59411bc3464b8f639af.tar.zst freebsd-ports-gnome-7e6b50eb965c8dc9ec31e59411bc3464b8f639af.zip |
sysutils/wmbluecpu builds under 8.0-CURRENT but exits as soon as run. It fails
due to a legacy kvm call being changed. (8.0 uses a sysctl, before used a kvm
call). This patch fixes that problem.
Pass maintainership to submitter.
PR: 121133
Submitted by: benjsc
-rw-r--r-- | sysutils/wmbluecpu/Makefile | 4 | ||||
-rw-r--r-- | sysutils/wmbluecpu/files/cpu_freebsd.c | 36 |
2 files changed, 22 insertions, 18 deletions
diff --git a/sysutils/wmbluecpu/Makefile b/sysutils/wmbluecpu/Makefile index 46a1ac3463b9..386634bdb03d 100644 --- a/sysutils/wmbluecpu/Makefile +++ b/sysutils/wmbluecpu/Makefile @@ -7,12 +7,12 @@ PORTNAME= wmbluecpu PORTVERSION= 0.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils windowmaker MASTER_SITES= ${MASTER_SITE_SUNSITE} MASTER_SITE_SUBDIR= X11/xutils -MAINTAINER= ports@FreeBSD.org +MAINTAINER= benjsc@FreeBSD.org COMMENT= A CPU monitoring dockapp USE_BZIP2= yes diff --git a/sysutils/wmbluecpu/files/cpu_freebsd.c b/sysutils/wmbluecpu/files/cpu_freebsd.c index 36440aea422a..62fb2a8fc7b7 100644 --- a/sysutils/wmbluecpu/files/cpu_freebsd.c +++ b/sysutils/wmbluecpu/files/cpu_freebsd.c @@ -35,23 +35,17 @@ #include <unistd.h> static kvm_t *kd; -static struct nlist nlst[] = { {"_cp_time"}, {0} }; +static int cp_time_mib[2]; +static struct nlist nlst[] = { + {"_cp_time"}, {0}}; void cpu_init(void) { - if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"))) - { - perror("kvm_open"); - exit(1); - } - - kvm_nlist(kd, nlst); - - if (!nlst[0].n_type) - { - perror("kvm_nlist"); - exit(1); + size_t len = 2; + sysctlnametomib("kern.cp_time", cp_time_mib, &len); + if((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) != NULL ){ + kvm_nlist(kd, nlst); } seteuid(getuid()); @@ -73,13 +67,23 @@ int history[17]; void cpu_getusage() { long cpu, nice, system, idle, used, total; - long cpu_time[CPUSTATES]; + long cpu_time[CPUSTATES], cpu_time_len=sizeof(cpu_time); + int error; - if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) + if( cp_time_mib[0] != 0 ){ + error = sysctl(cp_time_mib, 2, cpu_time, &cpu_time_len, NULL, 0 ); + if ( error ){ + perror("sysctl, cpu_time_mib"); + exit(1); + } + } + else { + if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) != sizeof(cpu_time)) - { + { perror("kvm_read"); exit(1); + } } cpu = cpu_time[CP_USER]; |