From owner-svn-src-head@freebsd.org Wed Feb 28 00:17:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE37AF3796D; Wed, 28 Feb 2018 00:17:09 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C9AC478CC4; Wed, 28 Feb 2018 00:17:08 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C4B4011FCE; Wed, 28 Feb 2018 00:17:08 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1S0H8Ho017157; Wed, 28 Feb 2018 00:17:08 GMT (envelope-from karels@FreeBSD.org) Received: (from karels@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1S0H8Qx017156; Wed, 28 Feb 2018 00:17:08 GMT (envelope-from karels@FreeBSD.org) Message-Id: <201802280017.w1S0H8Qx017156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: karels set sender to karels@FreeBSD.org using -f From: Mike Karels Date: Wed, 28 Feb 2018 00:17:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330091 - head/bin/ps X-SVN-Group: head X-SVN-Commit-Author: karels X-SVN-Commit-Paths: head/bin/ps X-SVN-Commit-Revision: 330091 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 00:17:09 -0000 Author: karels Date: Wed Feb 28 00:17:08 2018 New Revision: 330091 URL: https://svnweb.freebsd.org/changeset/base/330091 Log: Revert r314685 in ps Revert r314685, and add a comment describing the original behavior and the intent. Reviewed by: dab@ vangyzen@ jhb@ Differential Revision: https://reviews.freebsd.org/D14530 Modified: head/bin/ps/ps.c Modified: head/bin/ps/ps.c ============================================================================== --- head/bin/ps/ps.c Tue Feb 27 22:22:23 2018 (r330090) +++ head/bin/ps/ps.c Wed Feb 28 00:17:08 2018 (r330091) @@ -194,10 +194,17 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); time(&now); /* Used by routines in print.c. */ + /* + * Compute default output line length before processing options. + * If COLUMNS is set, use it. Otherwise, if this is part of an + * interactive job (i.e. one associated with a terminal), use + * the terminal width. "Interactive" is determined by whether + * any of stdout, stderr, or stdin is a terminal. The intent + * is that "ps", "ps | more", and "ps | grep" all use the same + * default line length unless -w is specified. + */ 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) ||