summaryrefslogtreecommitdiff
path: root/bin/ps
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/ps.113
-rw-r--r--bin/ps/ps.c26
2 files changed, 17 insertions, 22 deletions
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index d4b77f5b27c..9631a42202c 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ps.1,v 1.102 2015/10/22 22:21:41 benno Exp $
+.\" $OpenBSD: ps.1,v 1.103 2016/03/17 05:27:10 bentley Exp $
.\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
@@ -30,7 +30,7 @@
.\"
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\"
-.Dd $Mdocdate: October 22 2015 $
+.Dd $Mdocdate: March 17 2016 $
.Dt PS 1
.Os
.Sh NAME
@@ -543,10 +543,13 @@ The following environment variables affect the execution of
.Nm :
.Bl -tag -width "COLUMNS"
.It Ev COLUMNS
-If set, specifies the user's preferred output width in column positions.
-By default,
+If set to a positive integer,
+.Nm Ns 's
+output is formatted to the given width in columns.
+Otherwise,
.Nm
-attempts to automatically determine the terminal width.
+defaults to the terminal width \(mi 1, or 79 columns if the output is not a
+terminal.
.It Ev TZ
The time zone to use when displaying dates.
See
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index a7c4e43c812..ecbe683a04b 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ps.c,v 1.69 2016/01/10 14:04:16 schwarze Exp $ */
+/* $OpenBSD: ps.c,v 1.70 2016/03/17 05:27:10 bentley Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@@ -102,22 +102,14 @@ main(int argc, char *argv[])
setlocale(LC_CTYPE, "");
- if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
- const char *errstr;
-
- termwidth = strtonum(cols, 1, INT_MAX, &errstr);
- if (errstr != NULL)
- warnx("COLUMNS: %s: %s", cols, errstr);
- }
- if (termwidth == 0) {
- if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 &&
- ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 &&
- ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) ||
- ws.ws_col == 0)
- termwidth = 79;
- else
- termwidth = ws.ws_col - 1;
- }
+ termwidth = 0;
+ if ((cols = getenv("COLUMNS")) != NULL)
+ termwidth = strtonum(cols, 1, INT_MAX, NULL);
+ if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 &&
+ ws.ws_col > 0)
+ termwidth = ws.ws_col - 1;
+ if (termwidth == 0)
+ termwidth = 79;
if (argc > 1)
argv[1] = kludge_oldps_options(argv[1]);