Date: Mon, 10 Aug 2009 23:20:03 GMT From: Justin Hibbits <jrh29@alumni.cwru.edu> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/137647: ps output depends on terminals column width when piping or redirecting Message-ID: <200908102320.n7ANK3Dl098847@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/137647; it has been noted by GNATS.
From: Justin Hibbits <jrh29@alumni.cwru.edu>
To: bug-followup@freebsd.org, rivanr@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) ||
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908102320.n7ANK3Dl098847>
