From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 27 09:50:10 2012 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 3E865106564A for ; Fri, 27 Jan 2012 09:50:10 +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 14A168FC14 for ; Fri, 27 Jan 2012 09:50:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q0R9o9pY020626 for ; Fri, 27 Jan 2012 09:50:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0R9o91j020625; Fri, 27 Jan 2012 09:50:09 GMT (envelope-from gnats) Resent-Date: Fri, 27 Jan 2012 09:50:09 GMT Resent-Message-Id: <201201270950.q0R9o91j020625@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Marcus Reid Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C29AE1065672 for ; Fri, 27 Jan 2012 09:45:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id B167D8FC15 for ; Fri, 27 Jan 2012 09:45:15 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0R9jFAN011220 for ; Fri, 27 Jan 2012 09:45:15 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q0R9jFIB011219; Fri, 27 Jan 2012 09:45:15 GMT (envelope-from nobody) Message-Id: <201201270945.q0R9jFIB011219@red.freebsd.org> Date: Fri, 27 Jan 2012 09:45:15 GMT From: Marcus Reid To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/164535: ps(1) truncates command to screen size even when stdout is not a tty X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2012 09:50:10 -0000 >Number: 164535 >Category: bin >Synopsis: ps(1) truncates command to screen size even when stdout is not a tty >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 27 09:50:09 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Marcus Reid >Release: 9.0-STABLE >Organization: >Environment: FreeBSD seabug 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon Jan 9 10:53:27 PST 2012 root@seabug:/usr/obj/usr/src/sys/FARK amd64 >Description: ps(1) truncates long commands to the size of the screen even when stdout is not a terminal. This is counter-intuitive and differs from another implementation I looked at. Output of ps | grep differs depending on how big your terminal window is for example. >How-To-Repeat: ps aux | grep ps auxww | grep >Fix: Patch included. Tested; behavior remains consistent with docs: COLUMNS variable retains effect, and -w limits to 132 characters still. --- bin/ps/ps.c.orig 2012-01-27 01:24:10.519024952 -0800 +++ bin/ps/ps.c 2012-01-27 01:24:20.350023629 -0800 @@ -187,6 +187,8 @@ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') termwidth = atoi(cols); + else if (isatty(STDOUT_FILENO) == 0) + 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) || Patch attached with submission follows: --- bin/ps/ps.c.orig 2012-01-27 01:24:10.519024952 -0800 +++ bin/ps/ps.c 2012-01-27 01:24:20.350023629 -0800 @@ -187,6 +187,8 @@ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') termwidth = atoi(cols); + else if (isatty(STDOUT_FILENO) == 0) + 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) || >Release-Note: >Audit-Trail: >Unformatted: