Improve ps name parsing

Replaces #8489


My commit cleans up the name parsing logic in `ps`.  For more context about the original issue see the linked PR that this replaces.
I still think this is going to panic if for some reason a container isn't running and the # of lines is less