bin/90690: ps(1) errorneously respects terminal column settings
when output is not to a terminal
Oliver Fromme
olli at lurza.secnetix.de
Wed Dec 21 09:10:21 PST 2005
The following reply was made to PR bin/90690; it has been noted by GNATS.
From: Oliver Fromme <olli at lurza.secnetix.de>
To: bug-followup at FreeBSD.org, vadim_nuclight at mail.ru
Cc:
Subject: Re: bin/90690: ps(1) errorneously respects terminal column settings when output is not to a terminal
Date: Wed, 21 Dec 2005 18:00:06 +0100 (CET)
What you describe is standard BSD ps(1) behaviour, as is
documented in the manual page.
Basically, the intent is that, when you redirect ps(1) output
somewhere (to a file or pipe), you get exactly the same that
is displayed on the screen.
The rules are: If ps(1) is running in a terminal, it's width
is used. If it's not running in a terminal (e.g. via a cron
job) or the width cannot be determined, the default is 80
columns. To determine the terminal width, any one of stdout,
stderr or stdin is used -- therefore, to let ps(1) ignore the
terminal width, you have to redirect stderr and stdin.
If you specify the -w option once, the limit is expanded to
132 columns (unless your terminal width is already larger
than that). Finally, if you specify -w twice, the width is
assumed to be unlimited.
When you use ps(1) in a pipe to grep for things, you should
always use the -ww options. Also note that newer versions
of FreeBSD (> 4.x) have a pgrep(1) command which can be used
as a convenient replacement for ps | grep pipes.
Best regards
Oliver
--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
I suggested holding a "Python Object Oriented Programming Seminar",
but the acronym was unpopular.
-- Joseph Strout
More information about the freebsd-bugs
mailing list