ps and username size

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Jan 6 14:16:47 UTC 2008


On Sun, 6 Jan 2008, Denys Vlasenko wrote:


> Thanks for the report. Using %-8.8s instead of %-8s fixes this.
>
> I am also fixing VSZ overflow with large VSZs.
>
> Will commit changes to svn in a minute.

Thanks.
The attached patch properly adjusts the columns to the header and
immitates debian ps from procps-3.2.7-5.

bb-ps (revision 20806)

  PID USER       VSZ STAT COMMAND
    1 root      2080 S   init [2]
    2 root         0 SW< [kthreadd]
    3 root         0 SW< [migration/0]
    4 root         0 SWN [ksoftirqd/0]
    5 root         0 SW< [watchdog/0]
    6 root         0 SW< [migration/1]
    7 root         0 SWN [ksoftirqd/1]
    8 root         0 SW< [watchdog/1]
    9 root         0 SW< [events/0]

# ps -A -o pid,user,vsz,stat,command | head
  PID USER        VSZ STAT COMMAND
    1 root       2080 Ss   init [2]
    2 root          0 S<   [kthreadd]
    3 root          0 S<   [migration/0]
    4 root          0 SN   [ksoftirqd/0]
    5 root          0 S<   [watchdog/0]
    6 root          0 S<   [migration/1]
    7 root          0 SN   [ksoftirqd/1]
    8 root          0 S<   [watchdog/1]
    9 root          0 S<   [events/0]

patched bb-ps

  PID USER        VSZ STAT COMMAND
    1 root       2080 S    init [2]
    2 root          0 SW<  [kthreadd]
    3 root          0 SW<  [migration/0]
    4 root          0 SWN  [ksoftirqd/0]
    5 root          0 SW<  [watchdog/0]
    6 root          0 SW<  [migration/1]
    7 root          0 SWN  [ksoftirqd/1]
    8 root          0 SW<  [watchdog/1]
    9 root          0 SW<  [events/0]

I'm a bit unsure about the selinux adjustments.

The current svn chops of long usernames to 8 chars.  That may create
confusion if the output from ps is in any way used to identify process
owners.  Users:

  'longnameA' and 'longnameB' will both be displayed as 'longname'.

Please consider replacing usernames longer than 8 chars with the
corresponding uids.  That will make them unique in the ps list.


Cheers,

-- 
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ps.c.patch
Type: text/x-diff
Size: 890 bytes
Desc: 
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080106/648b7179/attachment-0002.bin 


More information about the busybox mailing list