Subject: Re: netbsd-4 (and -current) - ps acting funny ?
To: Michael van Elst <>
From: David Laight <>
List: current-users
Date: 07/28/2007 18:27:28
On Sat, Jul 28, 2007 at 03:56:40PM +0000, Michael van Elst wrote:
> (Frank Kardel) writes:
> >Sensible time output seem state dependent. Runnanble or Stopped
> >processes show time value that match my expectations more.
> The p_stat of a sleeping process is seen as SDYING (3) because
> the kvm interface overwrites the value with l_stat == LSSLEEP (3).
> A 'dying' process has no valid cputime, thus ps prints 0.

This is all fubar... 

When lwps were added (in the nathanw_sa branch) the 'process state'
needed by ps, had to come from the first/only/random lwp (since
processes no longer have running/sleeping states). So fill_kproc2()
got changed to do 'ki->p_stat = l->l_stat', since the values for
process and lwp status matched this didn't matter.

This all appeared to work until a new 'p->p_stat' flag SDYING got
added reusing one of the old values (instead of reusing the value
that used to be SDEAD).

This wouldn't be a problem except that:
1) SDYING also got added to the P_ZOMBIE() #define...
2) and the code in ps decides it can pass a 'struct kprocinfo2' to
3) Unfortunately this applies P_ZOMBIE() to an lwp l_stat value, and

Simple fix - remove the check from ps that disbelieves the time fields
for zombies.
(Committed to head.)


David Laight: