Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Mar 2001 09:51:34 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        mckusick@FreeBSD.org, current@FreeBSD.org, Alex Zepeda <jazepeda@pacbell.net>, Brooks Davis <brooks@one-eyed-alien.net>
Subject:   Re: very strange problem with ps
Message-ID:  <XFMail.010317095134.jhb@FreeBSD.org>
In-Reply-To: <20010317100216.A24957@walton.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help

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 <jhb@FreeBSD.org> -- 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




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