From owner-freebsd-current Sat Mar 17 9:52: 5 2001 Delivered-To: freebsd-current@freebsd.org Received: from moby.geekhouse.net (moby.geekhouse.net [64.81.6.36]) by hub.freebsd.org (Postfix) with ESMTP id CCD3E37B718; Sat, 17 Mar 2001 09:52:01 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: from laptop.baldwin.cx (john@dhcp152.geekhouse.net [192.168.1.152]) by moby.geekhouse.net (8.11.0/8.9.3) with ESMTP id f2HHs7189327; Sat, 17 Mar 2001 09:54:07 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20010317100216.A24957@walton.maths.tcd.ie> Date: Sat, 17 Mar 2001 09:51:34 -0800 (PST) From: John Baldwin To: David Malone Subject: Re: very strange problem with ps Cc: mckusick@FreeBSD.org, current@FreeBSD.org, Alex Zepeda , Brooks Davis Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 17-Mar-01 David Malone wrote: > On Fri, Mar 16, 2001 at 06:21:46PM -0800, Brooks Davis wrote: >> Ah, you are correct. I should have tried that. What a strange bug. > > It happens for any option which causes the sysctl to return no > processes to libkvm. (Try ps -p 100000). I think the following > patch should fix the problem. > > (Kirk changed the way the struct proc size was checked, and the > old way happened to work OK if no data was returned. Kirk, should > I go ahead and commit this?) > > David. I actually prefer the ESRCH patch as a) it better describes what happens and b) it returns a proper error when no processes are found, making it easier for other programs to detect this error condition. Programs should already be checking for a error return from the sysctlbyname() that they use to get this (or else they allow for kvm to inform them of errors) and thus won't need to add in special case checks for 'size > 0'. errno is the standard way of returning errors after all. :) -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message