diff options
| author | abs <abs@NetBSD.org> | 2000-04-29 00:18:48 +0000 |
|---|---|---|
| committer | abs <abs@NetBSD.org> | 2000-04-29 00:18:48 +0000 |
| commit | 22cfbf2cbbfae846eff6addeec786a285e8d49a0 (patch) | |
| tree | 29b9f45995fff6bc03b5ea222011a9b37d074bd7 /bin | |
| parent | 6a7a9484ecdb26d2ea848cfc382d7520bbb2153b (diff) | |
If ps cannot get the terminal size from STDOUT, it tried STDERR and STDIN.
What this does to the POLS when a script that is parsing ps output just happens
to run in a narrow terminal cannot be described in polite company.
If STDOUT is not a tty, leave width at 80.
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/ps/ps.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 6f4591d07c5..0ef4f8ec8c6 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.36 2000/04/15 04:40:46 simonb Exp $ */ +/* $NetBSD: ps.c,v 1.37 2000/04/29 00:18:48 abs Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.36 2000/04/15 04:40:46 simonb Exp $"); +__RCSID("$NetBSD: ps.c,v 1.37 2000/04/29 00:18:48 abs Exp $"); #endif #endif /* not lint */ @@ -123,9 +123,7 @@ main(argc, argv) char *ttname; (void)setegid(getgid()); - if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && - ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && - ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 || ws.ws_col == 0) termwidth = 79; else |
