Thursday, July 27, 2006

The crapness of old software

Last weekend I was bitching to Robert about how 'ps' was crap - it only displays 15 characters of the process name no matter how wide the console is.

e.g.

bob@alchemy2:~$ ps -A
PID TTY TIME CMD
1 ? 00:00:01 init
...
4995 ? 00:00:00 gnome-power-man


Sure the Gnome Power Man is a great process but other examples don't work so well. ;) So together we checked out the source (apt-get source procps) and had a crack at it.

Holy crap it is an obscure mess. I have previously found a bug in mount and it was a mission to track it down - that code is appalling too. Why is this old "base" code so crap?

Eventually I found out how the columns were generated in 'ps' and found the column is hard-coded to be of length 15. You could change it to be bigger but the columns can be ordered in any way so if you wanted a complex output it would be too wide. It looked like the column was supposed to expand if it the last one but I couldn't get the damn thing to work. The data is copied so many times through global variables it is too much of a mission.

So I gave up still not sure where the actual printf is...
Post a Comment