On Sun, Feb 19, 2023 at 12:04:22PM -0600, David Wright wrote: > But even that's not enough > because the field width is somewhat variable: try ps -eo '%c | %z | %a' > (We can still use | to make the problem somewhat more obvious.)
Oh wow. Yeah, OK, that's not really solvable. For those who don't want to try to reverse engineer David's conclusion, or who don't just happen to stumble upon it with their current process list, here's what I'm seeing: COMMAND | VSZ | COMMAND systemd | 164140 | /sbin/init kthreadd | 0 | [kthreadd] rcu_gp | 0 | [rcu_gp] rcu_par_gp | 0 | [rcu_par_gp] [...] steamwebhelper | 4631064 | /home/greg/.steam/debian-installation/[...] [...] chrome_crashpad | 33567792 | /opt/google/chrome/chrome_crashpad_handler[...] [...] kworker/3:0-eve | 0 | [kworker/3:0-events] ps appears to guess an initial maximum width for the VSZ field, but when a value comes along that exceeds the guessed maximum, it simply shoves the field barrier over. It doesn't even become the new maximum, with all of the fields aligning after that. It's just a one-time shove, breaking the current line only. Therefore, parsing the header line cannot give us enough information to insert field separators correctly in body lines after the fact.