From owner-freebsd-current Fri Oct 11 14:16:32 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA25945 for current-outgoing; Fri, 11 Oct 1996 14:16:32 -0700 (PDT) Received: from root.com (implode.root.com [198.145.90.17]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA25940 for ; Fri, 11 Oct 1996 14:16:29 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by root.com (8.7.5/8.6.5) with SMTP id OAA29959; Fri, 11 Oct 1996 14:16:17 -0700 (PDT) Message-Id: <199610112116.OAA29959@root.com> X-Authentication-Warning: implode.root.com: Host localhost [127.0.0.1] didn't use HELO protocol To: Gary Jennejohn cc: Poul-Henning Kamp , freebsd-current@FreeBSD.org Subject: Re: invalid return value from sysctl_kern_proc ? In-reply-to: Your message of "Fri, 11 Oct 1996 23:04:19 -0000." <199610112304.XAA06498@peedub.gj.org> From: David Greenman Reply-To: dg@root.com Date: Fri, 11 Oct 1996 14:16:17 -0700 Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >Poul-Henning Kamp writes: >>In message <199610111957.TAA05925@peedub.gj.org>, Gary Jennejohn writes: >[cruft deleted] >>>I ask because sysctl isn't returning an error when I try to get the proc >>>struct for a non-existent process. Seems to me that it should. >> >>Well, it does, you don't get any data back. >> >>sysctl doesn't return error for things in the data domain it handles, >>only errors about the handling. >> > >thanks alot, Poul-Henning ! > >this means that this code from kvm_getprocs in libkvm is wrong. > > if (size % sizeof(struct kinfo_proc) != 0) { > _kvm_err(kd, kd->program, > "proc size mismatch (%d total, %d chunks)", > size, sizeof(struct kinfo_proc)); > return (0); > } > >sysctl will set size = 0 if it can't find the requested data. This should >probably read > > if (!size || size % sizeof(struct kinfo_proc) != 0) { > ^^^^^^^ > >I used the code from libkvm, which didn't work as I expected it to. Um, well, if one were going to change it, one wouldn't want the error message to be the same in both cases. It probably also shouldn't be fatal since that will cause ps(8) to break most of the time on busy machines. -DG David Greenman Core-team/Principal Architect, The FreeBSD Project