aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-06-04 10:20:10 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-06-04 10:20:10 +0000
commit4f18100d731f35cd12b1ee01426959f16751313c (patch)
tree53988ee5729bf699707c493d2003f4605612b408 /bin/ps/ps.c
parenta28edf9a4a68207a93b90a9ba71617467957e257 (diff)
downloadsrc-4f18100d731f35cd12b1ee01426959f16751313c.tar.gz
src-4f18100d731f35cd12b1ee01426959f16751313c.zip
Respect setting of the COLUMNS environment variable (SUSv3)
Notes
Notes: svn path=/head/; revision=97804
Diffstat (limited to 'bin/ps/ps.c')
-rw-r--r--bin/ps/ps.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index dbc9a14b7438..be31a9202ff5 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -123,12 +123,15 @@ main(int argc, char *argv[])
uid_t *uids;
int all, ch, flag, i, _fmt, lineno, nentries, dropgid;
int prtheader, wflag, what, xflg, uid, nuids;
+ char *cols;
char errbuf[_POSIX2_LINE_MAX];
const char *nlistf, *memf;
(void) setlocale(LC_ALL, "");
- if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
+ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0')
+ termwidth = atoi(cols);
+ else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) ||
ws.ws_col == 0)