Fixed: wmcpuload exit with message "error extracting symbols"
With patch provided by Luke Dean <LukeD@pobox.com> PR: ports/123047 Submitted by: regisr <regisr@pobox.com>
This commit is contained in:
parent
6327aa3531
commit
ef7059dc50
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=214486
2 changed files with 55 additions and 4 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
PORTNAME= wmcpuload
|
||||
PORTVERSION= 1.0.1
|
||||
PORTREVISION= 3
|
||||
PORTREVISION= 4
|
||||
CATEGORIES= sysutils windowmaker
|
||||
MASTER_SITES= http://seiichisato.jp/dockapps/src/
|
||||
|
||||
|
|
|
@ -1,6 +1,57 @@
|
|||
--- src/cpu_freebsd.c.orig Sat Mar 8 03:40:25 2003
|
||||
+++ src/cpu_freebsd.c Wed Nov 30 13:42:56 2005
|
||||
@@ -75,7 +75,7 @@
|
||||
--- src/cpu_freebsd.c.orig 2008-05-03 07:05:31.000000000 +0200
|
||||
+++ src/cpu_freebsd.c 2008-05-03 07:12:09.000000000 +0200
|
||||
@@ -18,7 +18,8 @@
|
||||
#include <string.h>
|
||||
#include "cpu.h"
|
||||
|
||||
-#include <kvm.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -29,24 +30,18 @@
|
||||
# include <sys/resource.h>
|
||||
#endif /* __FreeBSD_version < 500101 */
|
||||
|
||||
-static kvm_t *kd = NULL;
|
||||
-static struct nlist nlst[] = { {"_cp_time"}, {0} };
|
||||
+static int sysctl_mib[2] = { -1, -1 };
|
||||
+static size_t sysctl_len;
|
||||
|
||||
void
|
||||
cpu_init(void)
|
||||
{
|
||||
|
||||
- kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
|
||||
+ sysctl_len = 2;
|
||||
+ sysctlnametomib("kern.cp_time", sysctl_mib, &sysctl_len);
|
||||
|
||||
- if (kd == NULL) {
|
||||
- fprintf(stderr, "can't open kernel virtual memory");
|
||||
- exit(1);
|
||||
- }
|
||||
-
|
||||
- kvm_nlist(kd, nlst);
|
||||
-
|
||||
- if (nlst[0].n_type == 0) {
|
||||
- fprintf(stderr, "error extracting symbols");
|
||||
+ if (sysctl_mib[0] == -1) {
|
||||
+ fprintf(stderr, "unknown sysctl kern.cp_time");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -68,14 +63,14 @@
|
||||
int used, total, result;
|
||||
unsigned long int cpu_time[CPUSTATES];
|
||||
|
||||
- if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) !=
|
||||
- sizeof(cpu_time))
|
||||
- return 0;
|
||||
+ sysctl_len = sizeof(cpu_time);
|
||||
+ if (sysctl(sysctl_mib, 2, &cpu_time, &sysctl_len, NULL, 0) == -1)
|
||||
+ return 0;
|
||||
|
||||
used = cpu_time[CP_USER] + cpu_time[CP_SYS];
|
||||
if (!opts->ignore_nice)
|
||||
used += cpu_time[CP_NICE];
|
||||
|
|
Loading…
Reference in a new issue