svn commit: r314685 - head/bin/ps
Bryan Drewery
bdrewery at FreeBSD.org
Tue Mar 7 04:11:50 UTC 2017
On 3/4/17 2:38 PM, Conrad Meyer wrote:
> Author: cem
> Date: Sat Mar 4 22:38:10 2017
> New Revision: 314685
> URL: https://svnweb.freebsd.org/changeset/base/314685
>
> Log:
> ps(1): Only detect terminal width if stdout is a tty
>
> If stdout isn't a tty, use unlimited width output rather than truncating to
> 79 characters. This is helpful for shell scripts or e.g., 'ps | grep foo'.
This change actually makes things worse for me for 'ps uaxwd|less'
Before:
> nobody 83979 0.0 0.0 9016 1364 3 I+J 20:03 0:00.06 | | `-- /usr/bin/make -C /usr/ports/lang/perl5.24 build
After:
> nobody 89743 0.0 0.0 9016 1368 3 S+J 20:07 0:00.05 | | `-- /usr/bin/make -C /usr/ports/lang/perl5.24
I now have to specify -ww to not cut things off, but that's far more
than I want to see.
>
> This hardcoded width has some history: In The Beginning of History[0], the
> width of ps was hardcoded as 80 bytes. In 1985, Bloom@ added detection
> using TIOCGWINSZ on stdin.[1] In 1986, Kirk merged a change to check
> stdout's window size instead. In 1990, the fallback checks to stderr and
> stdin's TIOCGWINSZ were added by Marc@, with the commit message "new
> version."[2]
>
> OS X Darwin has a very similar modification to ps(1), which simply sets
> UNLIMITED for all non-tty outputs.[3] I've chosen to respect COLUMNS
> instead of behaving identically to Darwin here, but I don't feel strongly
> about that. We could match OS X for parity if that is desired.
>
> [0]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?annotate=1065
> [1]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=18105&r2=18106
> [2]:
> https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=40675&r2=40674&pathrev=40675
> [3]:
> https://opensource.apple.com/source/adv_cmds/adv_cmds-168/ps/ps.c.auto.html
>
> PR: 217159
> Reported by: Deepak Nagaraj <n.deepak at gmail.com>
>
> Modified:
> head/bin/ps/ps.c
>
> Modified: head/bin/ps/ps.c
> ==============================================================================
> --- head/bin/ps/ps.c Sat Mar 4 22:23:59 2017 (r314684)
> +++ head/bin/ps/ps.c Sat Mar 4 22:38:10 2017 (r314685)
> @@ -194,6 +194,8 @@ main(int argc, char *argv[])
>
> 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) ||
>
--
Regards,
Bryan Drewery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20170306/5a53fc2d/attachment.sig>
More information about the svn-src-head
mailing list