From df1a6eb48bd60e210246bcfde6b57495071c3b09 Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 10 Sep 1998 18:06:28 +0000 Subject: Fixed breakage of %CPU and %MEM in the previous commit. sysctlbyname() was called with wrong args so it always failed. PR: 7881 --- bin/ps/nlist.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/ps/nlist.c b/bin/ps/nlist.c index 47aa6e9..d950e1b 100644 --- a/bin/ps/nlist.c +++ b/bin/ps/nlist.c @@ -31,8 +31,10 @@ * SUCH DAMAGE. */ -#include -#include +#include +#include + +#include fixpt_t ccpu; /* kernel _ccpu variable */ int nlistread; /* if nlist already read. */ @@ -42,12 +44,16 @@ int fscale; /* kernel _fscale variable */ int donlist() { + size_t oldlen; - if (sysctlbyname("kern.ccpu", &ccpu, sizeof ccpu, 0, 0) < 0) + oldlen = sizeof(ccpu); + if (sysctlbyname("kern.ccpu", &ccpu, &oldlen, NULL, 0) < 0) return (1); - if (sysctlbyname("kern.fscale", &fscale, sizeof fscale, 0, 0) < 0) + oldlen = sizeof(fscale); + if (sysctlbyname("kern.fscale", &fscale, &oldlen, NULL, 0) < 0) return (1); - if (sysctlbyname("hw.availpages", &mempages, sizeof mempages, 0, 0) < 0) + oldlen = sizeof(mempages); + if (sysctlbyname("hw.availpages", &mempages, &oldlen, NULL, 0) < 0) return (1); nlistread = 1; return (0); -- cgit v1.1