Bug 16084

Summary: [patch] ps f (forest) support non-DESKTOP
Product: Busybox Reporter: David <d+busybox>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: enhancement CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: [PATCH] ps: add f option (process forest)

Description David 2024-05-29 04:45:41 UTC
Created attachment 9748 [details]
[PATCH] ps: add f option (process forest)

I wanted to see the process tree in a hierarchy in the way that procps shows it.

The attached patch implements CONFIG_FEATURE_PS_FOREST. The output looks like this (in part):

   1883 root      2892 S    {run-cupsd} /bin/sh /snap/cups/1047/scripts/run-cupsd
   2104 root     69316 S     \_ cupsd -f -s /var/snap/cups/common/etc/cups/cups-files.conf -c /var/snap/cups/common/
   2105 root      236m S     \_ cups-proxyd /var/snap/cups/common/run/cups.sock /run/cups/cups.sock -l --logdir /var
   1908 root      116m S    {unattended-upgr} /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shu
   1929 root     1975m S    /usr/bin/containerd
   1969 colord    383m S    /usr/libexec/colord
   1977 root      2732 S    /usr/sbin/radvd --logmethod stderr_clean
   1978 root      2732 S     \_ /usr/sbin/radvd --logmethod stderr_clean
   1991 _chrony  19512 S    /usr/sbin/chronyd -F 1
   1992 _chrony  11208 S     \_ /usr/sbin/chronyd -F 1


Here is the bloatcheck

    function                                             old     new   delta
    forest_readdir                                         -    1037   +1037
    ps_main                                             1517    1833    +316
    static.de_ret                                          -     280    +280
    forest_layout_r                                        -     250    +250
    forest_bsearch                                         -     162    +162
    forest_proc_pidcmp                                     -      81     +81
    procps_scan                                         1592    1646     +54
    .rodata                                           120097  120137     +40
    free_procps_scan                                     113     130     +17
    top_main                                            2308    2320     +12
    mread_proc                                           203     212      +9
    pgrep_main                                          1289    1295      +6
    kill_main                                           1858    1864      +6
    packed_usage                                       34756   34760      +4
    ------------------------------------------------------------------------------
    (add/remove: 5/0 grow/shrink: 9/0 up/down: 2274/0)           Total: 2274 bytes
       text    data     bss     dec     hex filename
    1732374   16092    1808 1750274  1ab502 busybox_old
    1734368   16092    2088 1752548  1abde4 busybox_unstripped