From owner-freebsd-hackers Sat Oct 13 11: 6:36 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 88ED537B40D for ; Sat, 13 Oct 2001 11:06:32 -0700 (PDT) Received: (from dan@localhost) by dan.emsphone.com (8.11.6/8.11.6) id f9DI6Un67791; Sat, 13 Oct 2001 13:06:30 -0500 (CDT) (envelope-from dan) Date: Sat, 13 Oct 2001 13:06:29 -0500 From: Dan Nelson To: Paolo Pisati Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: First prg with sysctl Message-ID: <20011013130629.A58520@dan.emsphone.com> References: <20011013194902.A38183@newluxor.skynet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011013194902.A38183@newluxor.skynet.org> User-Agent: Mutt/1.3.23i X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Oct 13), Paolo Pisati said: > Someone can tell me why this piece of code doesn't work? The sysctl(3) manpage says that arg 4 is a pointer to the length of the storage area pointed to by arg 3. In fact, there's an example in the manpage: mib[0] = CTL_KERN; mib[1] = KERN_MAXPROC; len = sizeof(maxproc); sysctl(mib, 2, &maxproc, &len, NULL, 0); Note: always compile your programs with -Wall. gcc would have flagged this as: test.c:18: warning: passing arg 4 of `sysctl' makes pointer from integer without a cast -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message