bin/137647: ps(1) output depends on terminals column width when piping or redirecting

Bruce Evans brde at optusnet.com.au
Tue Aug 25 14:54:02 UTC 2009


On Tue, 25 Aug 2009 brian at FreeBSD.org wrote:

> Synopsis: ps(1) output depends on terminals column width when piping or redirecting
>
> State-Changed-From-To: open->closed
> State-Changed-By: brian
> State-Changed-When: Tue Aug 25 07:56:45 UTC 2009
> State-Changed-Why:
> I agree with Michael.  ps(1) checks stdout, stderr then stdin to see if
> it's a tty, and if none are will set the width to 79.
>
> Scripts should either use pgrep or pkill, or else use ps -ww and also
> possibly -o comm or -o command.

Er, don't you agree with me?  I sent a long reply, including to
bug-followup, but it isn't in the PR followup :-(.  Summary:
(1) checking stdin is bogus and is what causes this problem, but I
     can't see a better way to handle cases like "ps | less" where the
     output is redirected but the final output is still to a tty.
(2) handling of widths is mostly broken, starting with it mostly only
     applying to the last field.

Bruce


More information about the freebsd-bugs mailing list