[Bug 11826] New: ps pid/ppid/pgid fields truncated when kernel.pid_max > 99999

bugzilla at busybox.net bugzilla at busybox.net
Thu May 2 19:25:20 UTC 2019


            Bug ID: 11826
           Summary: ps pid/ppid/pgid fields truncated when kernel.pid_max
                    > 99999
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: josh at hoblitt.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

`ps` from all versions checked and the current `master` uses a hard-coded width
per field for output formatting.

>From `procps/ps.c`

static const ps_out_t out_spec[] = {
  /* Mandated by
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.ht  ml: */
      { 8                  , "user"  ,"USER"   ,func_user  ,PSSCAN_UIDGID  },
      { 8                  , "group" ,"GROUP"  ,func_group ,PSSCAN_UIDGID  },
      { 16                 , "comm"  ,"COMMAND",func_comm  ,PSSCAN_COMM    },
      { MAX_WIDTH          , "args"  ,"COMMAND",func_args  ,PSSCAN_COMM    },
      { 5                  , "pid"   ,"PID"    ,func_pid   ,PSSCAN_PID     },
      { 5                  , "ppid"  ,"PPID"   ,func_ppid  ,PSSCAN_PPID    },
      { 5                  , "pgid"  ,"PGID"   ,func_pgid  ,PSSCAN_PGID    },

This works when the linux sysctl `kernel.pid_max` is at its default of 32768. 
However, if the value set to > 99999, it creates the potential for the `pid`,
`ppid`, and `pgid` fields to be not only truncated upon output but with no
delimiting space between it and the right hand side adjacent field. Eg.,

/ # ps -efo pid,comm
    1 dockerd
   31 containerd

This is a bit of a disaster for programs that try to parse the output of `ps`
and I've recently run into this with `docker`. Eg.,


You are receiving this mail because:
You are on the CC list for the bug.

More information about the busybox-cvs mailing list