Re: svn commit: r330712 - head/bin/ps

2018-03-09 Thread Bruce Evans

On Sat, 10 Mar 2018, Mike Karels wrote:


...
Log:
 Change ps(1) output width to unlimited if not interactive
...



Modified: head/bin/ps/ps.1
==
--- head/bin/ps/ps.1Fri Mar  9 23:37:19 2018(r330711)
+++ head/bin/ps/ps.1Sat Mar 10 00:10:47 2018(r330712)
@@ -101,6 +101,14 @@ The default output format includes, for each process,
controlling terminal, state, CPU time (including both user and system time)
and associated command.
.Pp
+If the
+.Nm
+process is associated with a terminal, the default output width is that of the
+terminal; otherwise the output width is unlimited.


It is unclear how a process is assocated with a terminal and thus what this
width is.

For ps, unlike for most programs, a process is associated with a terminal
iff any of the 3 standard file descriptors is a terminal that supports the
TIOCGWINSZ ioctl, and the width of the preferred one is not 0.  The
preferred one is the first of STDOUT_FILENO, STDERR_FILENO and STDIN_FILENO
that supports the ioctl.

BUGS: if the first one somehow has width 0, then the process is considered
as not being associated with a terminal even of a later one has a nonzero
width.


...
Modified: head/bin/ps/ps.c
==
--- head/bin/ps/ps.cFri Mar  9 23:37:19 2018(r330711)
+++ head/bin/ps/ps.cSat Mar 10 00:10:47 2018(r330712)
@@ -202,6 +202,11 @@ main(int argc, char *argv[])
 * 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 not interactive, the default length was traditionally 79.
+* It has been changed to unlimited.  This is mostly for the
+* benefit of non-interactive scripts, which arguably should
+* use -ww, but is compatible with Linux.
 */


This belongs in the HOSTORY section of the man page, with version info
for the change.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330712 - head/bin/ps

2018-03-09 Thread Mike Karels
Author: karels
Date: Sat Mar 10 00:10:47 2018
New Revision: 330712
URL: https://svnweb.freebsd.org/changeset/base/330712

Log:
  Change ps(1) output width to unlimited if not interactive
  
  Apply patch submitted with PR 217159 to make ps use unlimited
  width when not associated with a terminal (i.e., none of stdout, stdin,
  or stderr is a tty). Update comments and man page correspondingly.
  This change was requested to work around lack of -ww in scripts from
  third-party packages, including Hadoop, and adds a small measure of
  Linux compatibility. Hopefully few if any non-interactive scripts
  depend on the old default of 79.
  
  PR:   217159
  Submitted by: n.deepak at gmail.com
  Reviewed by:  vangyzen jhb
  Differential Revision:https://reviews.freebsd.org/D14614

Modified:
  head/bin/ps/ps.1
  head/bin/ps/ps.c

Modified: head/bin/ps/ps.1
==
--- head/bin/ps/ps.1Fri Mar  9 23:37:19 2018(r330711)
+++ head/bin/ps/ps.1Sat Mar 10 00:10:47 2018(r330712)
@@ -101,6 +101,14 @@ The default output format includes, for each process, 
 controlling terminal, state, CPU time (including both user and system time)
 and associated command.
 .Pp
+If the
+.Nm
+process is associated with a terminal, the default output width is that of the
+terminal; otherwise the output width is unlimited.
+See also the
+.Fl w
+option.
+.Pp
 The options are as follows:
 .Bl -tag -width indent
 .It Fl -libxo
@@ -257,13 +265,15 @@ option implies the
 .Fl m
 option.
 .It Fl w
-Use 132 columns to display information, instead of the default which
-is your window size.
+Use at least 132 columns to display information, instead of the default which
+is the window size if
+.Nm
+is associated with a terminal.
 If the
 .Fl w
 option is specified more than once,
 .Nm
-will use as many columns as necessary without regard for your window size.
+will use as many columns as necessary without regard for the window size.
 Note that this option has no effect if the
 .Dq command
 column is not the last column displayed.

Modified: head/bin/ps/ps.c
==
--- head/bin/ps/ps.cFri Mar  9 23:37:19 2018(r330711)
+++ head/bin/ps/ps.cSat Mar 10 00:10:47 2018(r330712)
@@ -202,6 +202,11 @@ main(int argc, char *argv[])
 * 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 not interactive, the default length was traditionally 79.
+* It has been changed to unlimited.  This is mostly for the
+* benefit of non-interactive scripts, which arguably should
+* use -ww, but is compatible with Linux.
 */
if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
termwidth = atoi(cols);
@@ -209,7 +214,7 @@ main(int argc, char *argv[])
 ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)) == -1 &&
 ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)) == -1) ||
 ws.ws_col == 0)
-   termwidth = 79;
+   termwidth = UNLIMITED;
else
termwidth = ws.ws_col - 1;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"