Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 1996 14:16:17 -0700
From:      David Greenman <dg@root.com>
To:        Gary Jennejohn <Gary.Jennejohn@munich.netsurf.de>
Cc:        Poul-Henning Kamp <phk@critter.tfs.com>, freebsd-current@FreeBSD.org
Subject:   Re: invalid return value from sysctl_kern_proc ? 
Message-ID:  <199610112116.OAA29959@root.com>
In-Reply-To: Your message of "Fri, 11 Oct 1996 23:04:19 -0000." <199610112304.XAA06498@peedub.gj.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
>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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610112116.OAA29959>