ps command fields

Denys Vlasenko vda.linux at googlemail.com
Thu Feb 3 03:16:26 UTC 2011


On Wednesday 02 February 2011 15:34, David Collier wrote:
> trouble is, across the years, the "default output columns" have rather
> varied !
> so    ps|cut -f4 
> doesn't produce a very predictable result!

Don't use default columns. Specify exact columns you need
(and suppress headers) via -o col1= -o col2=
this should work on any standard-compliant ps.


> > > In the 1.13 one there is the option of a "stat" field 
> > 
> > Can you send the .config with which you have working "ps -o stat"?
> > 
> > # ./busybox ps -o stat
> > ps: bad -o argument 'stat'
> > # ./busybox | head -1
> > BusyBox v1.13.0 (2008-11-10 22:24:12 CET) multi-call binary
> 
> I obviously lied about it being in 1.13 :-(  it was in a much earlier
> version. So stat was there once :-)
> 
> # ps --help
> BusyBox v0.60.5 (2005.06.03-15:39+0000) multi-call binary
> 
> No help available.
> 
> # ps
>   PID TTY     Uid        Size State Command
>     1         root       1548   S   init            
>     2         root          0   S   [keventd]
> 
> I don't have any info on that system beyond what I find on it.
>     
> > > More to the point, if I don't have stat, can I be sure I won't 
> > > see zombie and terminated processes in the output of ps?
> > 
> > Looks like -o stat is not implemented.

I implemented it, will be in 1.19.x


> OK - but I still wonder if the zombie and terminated processes are going
> to be in the output of standard ps "looking like real processes"...

Yes, they will have Z there.


> I could always read the source I guess :-)
>  
> If I have asked a process to die, and am trying to confirm I was obeyed,
> I don't want to go panicking that it's still in the ps output when it's
> in fact a zombie, and on it's way out, slowly.
> 
> Can I go off and get the equivalent "I'm a zombie/terminated" info in
> /proc? I poked about yesterday but didn't spot it in an easily readable
> format...

# cat /proc/1/stat
1 (init) S 0 0 0 0 -1 4194560 332 2164285 17 420 0 41 9761 966 20 0 1 0 0 1032192 0 18446744073709551615 134512640 135387576 4286968432 4286967316 135129429 0 0 4 2 0 0 0 0 0 0 0 0 0 0
         ^
This is the stat field.


-- 
vda


More information about the busybox mailing list