aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-03-27 15:53:03 -0700
committerRob Landley <rob@landley.net>2017-03-28 09:34:00 -0500
commitaf39a2c46a6f899d298f63a270e8fd2338904ad3 (patch)
treec9829594654f8ae9f6f071627500485cd1774ca7 /toys
parent7ec23e64af0f0bfd6e330c2cff467ae8524d16dd (diff)
downloadtoybox-af39a2c46a6f899d298f63a270e8fd2338904ad3.tar.gz
ps: don't query for terminal size if not a tty.
`ps -A | cat` shouldn't have different output depending on the size of your terminal window.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/ps.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 0d79b5cb..f6906716 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -1149,8 +1149,10 @@ static void shared_main(void)
TT.width = 80;
TT.height = 25;
// If ps can't query terminal size pad to 80 but do -w
- if (!terminal_size(&TT.width, &TT.height) && toys.which->name[1] == 's')
- toys.optflags |= FLAG_w;
+ if (toys.which->name[1] == 's') {
+ if (!isatty(1) || !terminal_size(&TT.width, &TT.height))
+ toys.optflags |= FLAG_w;
+ }
}
// find controlling tty, falling back to /dev/tty if none