misc/137647: ps output depends on terminals column width when
piping or redirecting
Justin Hibbits
jrh29 at alumni.cwru.edu
Mon Aug 10 23:20:03 UTC 2009
The following reply was made to PR bin/137647; it has been noted by GNATS.
From: Justin Hibbits <jrh29 at alumni.cwru.edu>
To: bug-followup at freebsd.org, rivanr at gmail.com
Cc:
Subject: Re: misc/137647: ps output depends on terminals column width when
piping or redirecting
Date: Mon, 10 Aug 2009 18:49:57 -0400
This patch hasn't been tested with every possible tty, but it works
with xterm, vc, and redirect. There is one caveat, it breaks "ps aux
| less", if one wants a simple list.
(Gmail isn't cooperating, so patch is inline).
===================================================================
--- ps.c (revision 195790)
+++ ps.c (working copy)
@@ -187,6 +187,8 @@
if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
termwidth = atoi(cols);
+ else if (!isatty(STDOUT_FILENO))
+ termwidth = UNLIMITED;
else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) ||
More information about the freebsd-bugs
mailing list