Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 2012 09:45:15 GMT
From:      Marcus Reid <marcus@blazingdot.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/164535: ps(1) truncates command to screen size even when stdout is not a tty
Message-ID:  <201201270945.q0R9jFIB011219@red.freebsd.org>
Resent-Message-ID: <201201270950.q0R9o91j020625@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201270945.q0R9jFIB011219>