From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 10 23:20:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7BBB106566B for ; Mon, 10 Aug 2009 23:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 968638FC34 for ; Mon, 10 Aug 2009 23:20:03 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n7ANK3uQ098848 for ; Mon, 10 Aug 2009 23:20:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n7ANK3Dl098847; Mon, 10 Aug 2009 23:20:03 GMT (envelope-from gnats) Date: Mon, 10 Aug 2009 23:20:03 GMT Message-Id: <200908102320.n7ANK3Dl098847@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Justin Hibbits Cc: Subject: Re: misc/137647: ps output depends on terminals column width when piping or redirecting X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Justin Hibbits List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2009 23:20:03 -0000 The following reply was made to PR bin/137647; it has been noted by GNATS. From: Justin Hibbits 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) ||