From owner-freebsd-current Sat Oct 12 01:16:36 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id BAA09389 for current-outgoing; Sat, 12 Oct 1996 01:16:36 -0700 (PDT) Received: from critter.tfs.com ([140.145.230.177]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id BAA09382; Sat, 12 Oct 1996 01:16:30 -0700 (PDT) Received: from critter.tfs.com (localhost.tfs.com [127.0.0.1]) by critter.tfs.com (8.7.5/8.7.3) with ESMTP id KAA03182; Sat, 12 Oct 1996 10:15:54 +0200 (MET DST) To: Gary Jennejohn cc: 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> Date: Sat, 12 Oct 1996 10:15:54 +0200 Message-ID: <3180.845108154@critter.tfs.com> From: Poul-Henning Kamp Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk In message <199610112304.XAA06498@peedub.gj.org>, Gary Jennejohn writes: >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. No, that would be wrong. You would get the "proc size mismatch" message then for the case of "process not found" that would be wrong. -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@ref.tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.