ps and username size
Denys Vlasenko
vda.linux at googlemail.com
Mon Jan 7 08:36:46 PST 2008
On Sunday 06 January 2008 14:16, Cristian Ionescu-Idbohrn wrote:
> 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]
- len = printf("%5u %-8.8s %s %s ",
+ len = printf("%5u %-8.8s %6s %-4s ",
p->pid, user, buf6, p->state);
Re "%6s":
buf6 is always 5 chars long. With this patch, you have at least
two spaces between USER and VSZ. Not useful.
Re "%-4s":
Correct, p->state is always 3 chars. I will do it by adding
a space: "%s ".
> 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.
Good idea.
--
vda
More information about the busybox
mailing list